perf: cache read-heavy db queries with streamlit - #178
Merged
SharanyaAchanta merged 2 commits intoMar 3, 2026
Conversation
Thanks for creating a PR for your Issue!
|
Owner
|
Hey, thanks for the PRs! I was caught up with other merges yesterday. Since today is the final day, I’m wrapping things up. I see some checks are failing now—if you can resolve them quickly, let me know. If not, no worries at all, thanks for your contribution! |
Contributor
Author
|
@SharanyaAchantai have made the changes can youcheck it out! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
@st.cache_datafor DB Read Operations #136Rationale for this change
Read-heavy database query functions like
get_all_mappings()andget_categories()executed a SQLite lookup directly on every UI re-render, leading to excessive I/O overhead and UI lag.What changes are included in this PR?
engine/db.py(e.g.get_mapping,get_all_mappings,get_categories,get_mapping_count,get_metadata) with@st.cache_data(ttl=3600)._clear_db_cache()helper to forcefully clear thest.cache_dataobject whenever mutation functions occur (likeinsert_mapping,update_mapping,migrate_from_json, orrestore_database).Are these changes tested?
Yes, existing
pytestintegration and database utility tests passed and correctly handled the added caching logic.Are there any user-facing changes?
Noticeable improvements in overall application performance and responsiveness, due to minimizing database queries across component renders. No functional changes were made to endpoints or structures.