Slow Queries
Slow Queries is a feature that helps you identify slow queries in your database. This feature is implemented based on MySQL Slow Query Logs and PostgreSQL pg_stat_statements.
Enable Slow Queries in Database
Before you can use this feature, you need to enable slow query logs in your database. Please refer to the following instructions:
Turn on Slow Queries Report in Bytebase
After you enable slow query logs in your database, you can turn on the Slow Queries Report in Bytebase. Only the workspace owner and DBA can turn on/off the Slow Queries Report.
-
Go to the Settings page in Bytebase.
-
Go to the Slow Query tab.
-
Click the Report button to turn on the Slow Queries Report for instances.
If you don't enable slow query logs in your database, you will not be able to turn on the Slow Queries Report and get an error.
View Slow Queries
After you turn on the Slow Queries Report, you can view the slow queries in the Slow Queries page.
You can filter the slow queries by environment, instance, database, and date range. Bytebase orders the slow queries by the maximum execution time in descending order.
Bytebase will sync the slow queries from the database every 12 hours. You can also click the Sync Now button to sync the slow queries immediately. Bytebase only stores the slow queries in the last 30 days. Bytebase will hard delete the slow queries older than 30 days.
Specifically, you can view the Slow Query Detail for each MySQL slow query.
Slow Query Weekly Summary Report
Bytebase will send a weekly summary report to the workspace owner, DBA, and project owner. This feature requires configuring the SMTP server in the workspace settings. Currently, Bytebase will send the weekly summary report every Saturday at 0:00 ~ 1:00 AM.
The weekly summary report for workspace owner and DBA includes the following information:
- All slow queries in the workspace in the last week.
- The slow queries will be grouped by environment, instance, database.
- Each database will report the top 5 slow queries.
The weekly summary report for project owner includes the following information:
- All slow queries in the project in the last week.
- The slow queries will be grouped by environment, instance, database.
- Each database will report the top 5 slow queries.