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, and CLI.
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.
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 active mysql_slow_query_log
status.
$ 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 the mysql_slow_query_log
status.
$ 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
}'
List all database instances and note the database ID. For instance, d6ac2a3c-92ea-43ef-8185-71a23e58ad8c
.
$ vultr-cli database list --summarize
Run the following command and specify a database ID to update mysql-slow-query-log
and mysql-long-query-time
.
$ vultr-cli database update database_id \
--mysql-slow-query-log true \
--mysql-long-query-time 20