The beauty of ORM lulled me into a soporific sleep. I’ve got an existing Django app with a lack of database indexes. Is there a way to automatically generate a list of columns that need indexing?
I was thinking maybe some middleware that logs which columns are involved in WHERE clauses? but is there anything built into MySQL that might help?
Yes, there is.
If you take a look at the slow query log, there’s an option
--log-queries-not-using-indexes