I have a 73 GB big table table1
. Most of my queries involve fetching the latest 100 entries in the table which satisfy some condition. I am using Django as my backend for this web app. My query is something similar to this:
table_object = table1.objects.filter(first_filter_field=6)
order_by = '-created_on'
table_object = .filter(not_null_field__isnull=False).order_by(order_by)
table_object = table_object[offset:(offset + limit)]
I think this query takes too much time.
- How can I measure the time taken by this query? (in Postgres)
- How can I improve its performance? I just need latest 100 creatives which satisfy some condition (basically WHERE statement addition in normal query.)
I am new to Django, so please be descriptive and give links to the related material wherever possible.