How to Manage Slow Query Logging for Vultr Managed Databases for MySQL
-
by Blog Admin
- 11
How to Manage Slow Query Logging for Vultr Managed Databases for MySQL
A guide for configuring and managing slow query logging to identify performance issues in Vultr Managed MySQL databases.
Slow Query Logging instructs MySQL to store SQL statements that take long to execute. The log allows you to identify and optimize such queries to improve your application’s performance. Optimizing queries reduces the CPU and memory usage causing your database to run more efficiently. Running faster queries also lead to a more responsive and enjoyable user experience.
Follow this guide to manage slow query logging for Vultr Managed Databases for MySQL using Vultr Customer Portal, API, CLI, or Terraform.
Vultr Customer Portal
- Navigate to Products and select Databases.
- Click the target database instance.
- Click Settings and select MySQL Configuration.
- Then, navigate to Slow Query Logging.
- Turn the feature to YES or NO and click Apply Changes.
- If you turn the feature to YES specify a Long Query Time value in seconds. The minimum value is
10
seconds.
Vultr API
- List all the database instances by sending a
GET
request to the List Managed Databases endpoint and note the database ID (For example,43b4c774-5dff-4ac0-a01f-78a23c2205b5
) and the activemysql_slow_query_log
status.console$ curl "https://api.vultr.com/v2/databases" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}"
- Send a
PUT
request to the Update Managed Database endpoint and specify the database ID to change themysql_slow_query_log
status.console$ curl "https://api.vultr.com/v2/databases/database_id" \ -X PUT \ -H "Authorization: Bearer ${VULTR_API_KEY}" \ -H "Content-Type: application/json" \ --data '{ "mysql_slow_query_log": false }'
Vultr CLI
- List all database instances and note the database ID. For instance,
d6ac2a3c-92ea-43ef-8185-71a23e58ad8c
.console$ vultr-cli database list --summarize
- Run the following command and specify a database ID to update
mysql-slow-query-log
andmysql-long-query-time
.console$ vultr-cli database update database_id \ --mysql-slow-query-log true \ --mysql-long-query-time 20
Terraform
- Open your Terraform configuration for the existing Managed Database for MySQL resource.
- Add or update the
mysql_slow_query_log
andmysql_long_query_time
arguments.terraformresource "vultr_database" "mysql" { # ...existing fields (database_engine, region, plan, label, etc.) mysql_slow_query_log = true mysql_long_query_time = 20 }
- Apply the configuration and observe the following output:
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
How to Manage Slow Query Logging for Vultr Managed Databases for MySQL A guide for configuring and managing slow query logging to identify performance issues in Vultr Managed MySQL databases. Slow Query Logging instructs MySQL to store SQL statements that take long to execute. The log allows you to identify…
How to Manage Slow Query Logging for Vultr Managed Databases for MySQL A guide for configuring and managing slow query logging to identify performance issues in Vultr Managed MySQL databases. Slow Query Logging instructs MySQL to store SQL statements that take long to execute. The log allows you to identify…