Some random thoughts:
-
Depending on how unique the database queries are, have you tried to use
pn.cache
? More ideas here on caching Discussion on best practices for advanced caching - please join - #14 by jbednar -
DuckDB is a great replacement for SQLite, but I assume your database isn’t SQLite
-
Async is probably a good way forward, and with Panel magic, you don’t have to convert your entire app to become async, just your database queries. Just link it to a widget, like I did in ChatInterface here, here, and here.
-
Maybe you could involve dask? Asynchronous Operation — Dask.distributed 2023.10.1 documentation