---
title: Slow Query Logging
url: https://docs.vultr.com/products/storage/databases/mysql/management/settings/slow-query-logging
description: A guide for configuring and managing slow query logging to identify performance issues in Vultr Managed MySQL databases.
publish_date: 2024-09-23T20:21:37.351502Z
last_updated: 2026-05-26T20:35:51.826875Z
---

# How to Manage Slow Query Logging for Vultr Managed Databases for MySQL

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 Console, API, CLI, or Terraform.

=== "Vultr Console"

    1. Navigate to **Products** and select **Databases**.
    1. Click the target database instance.
    1. Click **Settings** and select **MySQL Configuration**. 
    1. Then, navigate to **Slow Query Logging**. 
    1. Turn the feature to **YES** or **NO** and click **Apply Changes**. 
    1. If you turn the feature to **YES** specify a **Long Query Time** value in seconds. The minimum value is `10` seconds.

=== "Vultr API"

    1. List all the database instances by sending a `GET` request to the [**List Managed Databases** endpoint](https://www.vultr.com/api/#tag/managed-databases/operation/list-databases) and note the database ID (For example, `43b4c774-5dff-4ac0-a01f-78a23c2205b5`) and the active `mysql_slow_query_log` status.

        ```console
        $ curl "https://api.vultr.com/v2/databases" \
            -X GET \
            -H "Authorization: Bearer ${VULTR_API_KEY}"
        ```

    1. Send a `PUT` request to the [**Update Managed Database** endpoint](https://www.vultr.com/api/#tag/managed-databases/operation/update-database) and specify the database ID to change the `mysql_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"

    1. List all database instances and note the database ID. For instance, `d6ac2a3c-92ea-43ef-8185-71a23e58ad8c`.

        ```console
        $ vultr-cli database list --summarize
        ```

    1. Run the following command and specify a database ID to update `mysql-slow-query-log` and `mysql-long-query-time`.

        ```console
        $ vultr-cli database update database_id \
        --mysql-slow-query-log true \
        --mysql-long-query-time 20
        ```

=== "Terraform"

    1. Open your Terraform configuration for the existing Managed Database for MySQL resource.

    1. Add or update the `mysql_slow_query_log` and `mysql_long_query_time` arguments.

        ```terraform
        resource "vultr_database" "mysql" {
            # ...existing fields (database_engine, region, plan, label, etc.)

            mysql_slow_query_log = true
            mysql_long_query_time = 20
        }
        ```

    1. Apply the configuration and observe the following output:

        ```
        Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
        ```
