Slow Query Logs
Slow query logs provide the ability to identify queries made by an application that take an unusually long time to execute. Slow queries should be optimized in order to improve database efficiency and overall responsiveness of an application.
Logs for up to 100 of the most recent slow queries that have occurred on an environment can be accessed:
- In the Slow Query Logs panel located in the application view of the VIP Dashboard.
- In the command line using VIP-CLI.
Details related to each slow query are provided to assist customers with investigating the source of a slow query and improve its performance.
Access
Prerequisite
- To access Slow Query Logs in the VIP Dashboard or with VIP-CLI, a user must have at minimum an Org member role or an App write role for that application.
- For users with an App write role, sensitive data will be obfuscated with
?
characters.
To access the Slow Query Logs panel in the VIP Dashboard:
- Navigate to the VIP Dashboard for an application.
- Select “Logs” from the sidebar navigation at the left of the screen.
- Select “Slow Query” from the submenu.
The Slow Query Logs panel is environment-specific (e.g., production, develop). A different environment can be selected from the dropdown at the upper left of the VIP Dashboard application view.
Information displayed
Slow queries are listed in order of the most to the least recent. Information related to each slow query is displayed across 3 columns.
- Time (UTC): The timestamp in UTC when the slow query occurred.
- Duration: The statement execution time in seconds.
- SQL: The SQL statement that triggered the slow query.
- Request URL: The URL on which the slow query occurred.
- Rows sent: The number of rows sent to the client.
- Rows examined: The number of rows examined by the server layer.
Filter logs
The displayed logs can be filtered by searching for specific strings. Enter a value to filter by in the search field located in the upper right of the panel labeled “Search form“.
Export logs as a CSV
In the VIP Dashboard, export a copy of the displayed logs as a CSV file by selecting the button labeled “Download as CSV” located in the upper right of the panel. If the displayed logs are filtered by a search term, only the filtered results will be included in the downloaded CSV file.
In VIP-CLI, specify slow query logs to be output in CSV format by passing the --format=csv
option with the vip slowlogs
command. For example:
$ vip @example-app.develop slowlogs --format=csv
Debugging resources
Underlying causes for slow queries might not be immediately apparent, and more in-depth debugging may be needed. Stack traces for the provided Request URL value of a slow query can be reviewed by viewing the URL in a browser window with Query Monitor enabled. The Queries panel available in Query Monitor can provide detailed information about the Query, Caller, and Time elapsed for execution for each SQL query sent to the database by the current page.
Last updated: October 31, 2024