Improving Django Filter Query Performance

I am developing a Django admin shell around a PostgreSQL data warehouse application that has several tables with millions of records.

The admin list page, without any list filters, loads in a second, but if I include some columns in admin list_filters, it will load very slowly and can take anywhere from 30 seconds to a minute.

While checking the database, I saw several queries like:

SELECT DISTINCT "warehouse_data"."filter_field1" FROM "warehouse_data" ORDER BY "warehouse_data"."filter_field1" ASC;

each takes only 3-5 seconds, but where there are a dozen of them, they add up. All fields are indexed, so I'm not sure how else I can speed them up. How to increase administrator productivity? How can I enable the Django caching mechanism to cache the current requests of these list filters?

+4
source share

Source: https://habr.com/ru/post/1529297/


All Articles