1๐
-
Filters in Django are converted into WHERE statements with ANDs. You can in usually speed up those queries by putting an index on each field that is used in the filter statement, e.g.
order_date
,country
,order_status
,quote_status
,purchase_status
,user_name
. Be aware though that which index a DBMS uses can vary and you want to run a query profiler, e.g. SQL EXPLAIN to understand which indexes have the expected effect. -
I would have expected fields like country and user to be foreign keys, not simple lists. If you have FKs you want to add
select_related()
to your query to make sure you are doing a SQL join and not loading them one by one. -
For best results I recommend using a profiler like django-debug-toolbar, which can help a lot to identify bottlenecks in your queries and find the right approach.