Just wondering if I am taking the right path or if there is better alternative.
Just wondering if I am taking the right path or if there is better alternative.
> 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.
(But it's mostly for small personal projects, so grain of salt and all.)
If complex, what does Sqlalchemy output as the SQL? Could you optimise the query? If quite complex, optimise the tables by redesigning them?
Was the move to allow Redis to cache persistently across requests? Does it do this?
Are you timing each function to look for slowness?