Skip to main content
Question

Applying a filter on Streamlit is consuming time to give me results

  • October 30, 2024
  • 3 replies
  • 52 views

Forum|alt.badge.img+1

Hi Team, 

I am trying to develop a Streamlit app. When I am chaning the filter condition it is taking longer than expected time to apply those filters and fetch me the data I want. 

3 replies

APSHANKAR Sagar
Seasoned ⭐️⭐️
  • Seasoned ⭐️⭐️
  • October 30, 2024

Hello @Rajendra Pasupuleti , in my  experience, filters apply quickly but the various preprocessing steps before the filter can take time. Try to put everything that will always return the same value in functions and decorate the function with st.cache_data. 


Forum|alt.badge.img+1

When the data volume is in thousands it is working fine but when the data grows into more than 200K+ it’s taking very long. I do have st.cache_data on my code. 


Forum|alt.badge.img+4
  • Practitioner ⭐️⭐️
  • October 30, 2024

Hello @Rajendra Pasupuleti , in my  experience, filters apply quickly but the various preprocessing steps before the filter can take time. Try to put everything that will always return the same value in functions and decorate the function with st.cache_data. 

Yes this method solves the issue with Data Retrieval and Filtering. In case if it doesn't it may be worthwhile to validate the Filtering logic( for example switching for Loop with a lambda function)