Search code examples
drupal-7

Drupal 7 - How can we debug SQL query errors


I am new to Drupal, and while interacting with database sometimes I get this error:

Error
The website encountered an unexpected error. Please try again later.

How do I debug this issue? How can I can see which and what query is causing the issue?


Solution

  • Have a look at Drupal Devel Module. After enabling it, in the config page (Admin > Configuration > Development > Development Options) you should check the first option.

    Checkbox that should be selected (sorry, mine is in Spanish!)

    Then, you will see a list of queries to the database every time you load a page. The time needed to perform the query is also shown. This way you can identify which queries have a bad performance.

    Hope it helps