Ensure that the "slow_query_log" database flag is enabled for your Google Cloud MySQL database instances in order to simplify the task of finding inefficient or time-consuming SQL queries for your MySQL databases. By default, the "slow_query_log" database flag is not enabled for Google Cloud MySQL instances.
efficiency
The slow query log feature designed for MySQL databases enables you to log queries that exceed a predefined time limit. By enabling the "slow_query_log" flag, you can keep an eye on your MySQL database performance, allowing you to identify which queries need optimization. Optionally, you can integrate these logs with Google Cloud Operations service (formerly Stackdriver) to create and configure alerts that can send you notifications when there are too many slow queries and your database performance is downgraded.
Note: Some database flag settings can affect instance availability and/or stability, and eventually remove the MySQL instance from the Google Cloud SQL Service Level Agreement (SLA).
Audit
To determine if "slow_query_log" flag is enabled for your MySQL database instances, perform the following operations:
Remediation / Resolution
To enable the "slow_query_log" database flag for your Google Cloud Platform (GCP) MySQL database instances, perform the following actions:
References
- Google Cloud Platform (GCP) Documentation
- Cloud SQL for MySQL
- Configuring database flags
- Editing instances
- Monitoring slow queries in MySQL with Cloud Logging and Monitoring
- MySQL Database Documentation
- 5.1.7 Server System Variables
- GCP Command Line Interface (CLI) Documentation
- gcloud projects list
- gcloud sql instances list
- gcloud sql instances describe
- gcloud sql instances patch