SQL queries debugging

SQL queries debugging can be turned on by adding the following keys to the web.config file of your web project:

 

This key will make the SQL debug tab visible in Site Manager -> Administration -> System. On this tab, you can see a log  of debugged pages SQL queries history.

 

<add key="CMSDebugSQLQueries" value="true" />

 

 

The value property of this key determines the number of last loaded pages displayed in the previously mentioned log.

 

<add key="CMSDebugSQLQueriesLogLength" value="10" />

 

 

You can see the appearance of the log in the screenshot below. For each record, there is row with a URL of the loaded page followed by its time of display. Below it, you can find a table listing all SQL queries executed when loading the page.

 

For each query, there are two lines in the table. The first line contains the exact text of the query, while the second line contains the number of loaded rows, columns in each row and the size of the loaded data.

 

The Context column shows where the query was called from. The last column of the table displays the exact duration of query execution. The last line of the table displays the overall page loading time.

 

clip0799

 

There are also different ways of displaying the query log:

 

The following key will turn on SQL debugging in Live site mode.

 

<add key="CMSDebugSQLQueriesLive" value="true" />

 

A log table of all SQL queries executed when loading a page will be displayed on the bottom of the page, as you can see in the following screenshot:

 

clip0800

 

 

Adding this key will turn on logging SQL queries into a file. All executed SQL queries will be logged into <web root>/AppData/logsql.log:

 

<add key="CMSLogSQLQueries" value="true" />

 

If you want to use SQL debugging on ASPX page templates, you need to manually add the following control to the page. It will display the same queries table as in the Live site mode debugging described above.

 

<cms:QueryLog ID="logQuery" runat="server" />