django / djangoproject.com

Source code to djangoproject.com
https://www.djangoproject.com/
BSD 3-Clause "New" or "Revised" License
1.86k stars 939 forks source link

Added index on `aggregator_feeditem (date_modified DESC)` #1517

Closed tobiasmcnulty closed 2 months ago

tobiasmcnulty commented 2 months ago

For pages early in the aggregator/community feeds, there is a tremendous speedup when an index is added on aggregator_feeditem (date_modified DESC) (i.e., in the order in which the FeedItems are returned). In my tests, it reduced the query time from ~170ms to ~6ms. The change will help reduce load on the database server and free up uWSGI processes for other requests.

tobiasmcnulty commented 2 months ago

Thanks for the review!

One nitpick I had would be to change the name of the migration file to something slightly more readable. Maybe 0005_feeditem_add_index_date_modified.py. What do you think?

That is a favorite nitpick of mine, I am surprised I let it slip, lol. Updated!