Cache table info on SQLDatabase #26151
franklinlindemberg
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checked
Feature request
On SQLDatabase, it would be nice if we could cache the table info on get_table_info to avoid doing another database call.
Motivation
Currently everytime get_table_info is called, it hits the database to fetch the table info. This can have a huge impact on a high load environment since it will be always fetching the same table information, which is not expected to change very often.
One possible way to avoid that today is to inject the custom_table parameter when creating the SQLDatabase instance, but that requires more effort since we need to have definition in code. On the other hand, if we could just cache the information when it fetches from the database, we would still have tables information and avoid doing multiple calls.
Proposal (If applicable)
Ideally we would update get_table_info to have a table_info cache, and on every get_table_info call, if the table exists in table_info cache we just use it, otherwise we fetch it from the database and update the cache.
We might want to consider whether this cache should be refreshed or if it could just be static during the whole lifecycle of the application (considering table infos dont change much).
I can work on a solution for this, just wondering if it's something people would be interested as well
Beta Was this translation helpful? Give feedback.
All reactions