|
|
|
|
|
by greenSunglass
1249 days ago
|
|
I've been working on a project with flask + sqlalchemy. I have those sql queries returning a bit of rows (up to 20k) and that are quite slow. SQLalchemy does not seem to support caching the results and I've started to use flask-caching[1] with redis using the @cache.memoize() decorator. Just wondering if I am taking the right path or if there is better alternative. [1]https://flask-caching.readthedocs.io |
|
> Just wondering if I am taking the right path or if there is better alternative.
Yes, this can be a fine solution to slow queries and is used very often in many kinds of web applications.
However... 20k rows is not a very big number for a modern dB. If the db query is really the slow part then you should investigate why - ensure the relevant sql queries are written properly, and that the relevant tables are indexed properly for the queries that you are running on them.