Often slow queries are generated by some Drupal View in a website. But from looking a slow MySQL query itself, you have no indication of which View the query came from, or even the query even came from a Drupal View at all. This tip gs a long way towards solving that problem, by highlighting a configuration option in Drupal that adds signature to each query generated by a View that includes the name of the View that generated it. In the opinion of many this option should be enabled by default, since should have little impact on performance.
These instructions are for Drupal 8, but the same option exists in Drupal 7.
cat slow.log | egrep -o "\S+'\ \AS\ view_name" | awk '{print $1}' | sort | uniq -c | sort -nr | head
slow_query_log_[sitename]_[timestamp:1349352001].sql
(If you cannot run the command line, you can search for the string "AS view_name" in a the text editor of your choice.)
In general, when troubleshooting slow queries, you should also turn on the Views setting to show the query above a Views preview when editing each view in the Views UI module:
With this setting, you can see the SQL query that is made with the view when editing the View with the Views UI module, then you will fully understand what to search for in the slow query logs, and this entire method will become clear.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Wed Oct 22 2025 08:59:29 GMT+0000 (Coordinated Universal Time)