# Mariadb Slow log
/var/log/mysql/mariadb-slow.log is the standard file path used to store the slow query log in MariaDB and MySQL databases on Linux systems.** This log records any SQL queries that exceed a defined execution time threshold, helping database administrators diagnose and troubleshoot performance bottlenecks. [[1](https://mariadb.com/docs/server/server-management/server-monitoring-logs/slow-query-log/slow-query-log-overview), [2](https://nirsa.tistory.com/227), [3](https://support.cpanel.net/hc/en-us/articles/360052538914-How-to-Enable-the-Slow-Query-Log-in-MySQL-or-MariaDB), [4](https://support.sciencelogic.com/s/article/1098)]slow_query_log**: Should be ON to record queries.
- **slow_query_log_file**: Path to the log file (e.g., /var/log/mysql/mariadb-slow.log).
- **long_query_time**: The threshold in seconds. Queries taking longer than this value are logged. \[[1](https://support.plesk.com/hc/en-us/articles/12377515355031-How-to-enable-the-MySQL-MariaDB-slow-query-log-and-analyze-it-on-a-Plesk-for-Linux-server), [2](https://mosei.tistory.com/entry/MysqlMariaDB-Slow-Query-Log-%EC%84%B8%ED%8C%85), [3](https://da-new.tistory.com/250), [4](https://technoroots.org/insights/how-to-enable-mysql-slow-query-log-complete-setup-guide-PnQYT)\]
/etc/my.cnf, /etc/mysql/my.cnf, or /etc/mysql/mariadb.conf.d/50-server.cnf): [[1](https://gombach7.tistory.com/16), [2](https://support.plesk.com/hc/en-us/articles/12377515355031-How-to-enable-the-MySQL-MariaDB-slow-query-log-and-analyze-it-on-a-Plesk-for-Linux-server), [3](https://technoroots.org/insights/how-to-enable-mysql-slow-query-log-complete-setup-guide-PnQYT)]mysql system user must write to this file, the directory and file permissions must be configured correctly in Linux: [[1](https://docs.cpanel.net/knowledge-base/sql/how-to-enable-the-slow-query-log-in-mysql-or-mariadb/), [2](https://nirsa.tistory.com/227)]cat or vi, use native parsing tools: [[1](https://discuss.frappe.io/t/how-do-i-turn-on-and-then-view-mariadb-slow-query-log-with-v10/70826), [2](https://support.plesk.com/hc/en-us/articles/12377515355031-How-to-enable-the-MySQL-MariaDB-slow-query-log-and-analyze-it-on-a-Plesk-for-Linux-server)]mysqldumpslow**: A built-in command-line tool that groups similar queries together and sorts them by execution time.pt-query-digest**: Part of the advanced Percona Toolkit, this creates highly detailed and easily readable performance summaries.log_queries_not_using_indexes, the log captures queries performing full table scans.
- **Easy fixes:** Adding a single index to a column flagged in this log can often drop a query's execution time from 3 seconds to 3 milliseconds.
mariadb-slow.log.1 is not normal for a healthy, optimized production database.**.1 extension indicates this is a **rotated log file** (an older log preserved by Linux logrotate), meaning your database generated 3 GB of slow query data in a single log rotation period—typically just one week or one day.log_queries_not_using_indexes is ON:** If this setting is enabled, MariaDB logs **every single query** that doesn't use an index, even if it executes in 0.001 seconds. On a busy site, this will inflate the log file to gigabytes in hours.
3. **long_query_time is set too low:** If this is set to 0 or a very low fraction (like 0.01 seconds) on a high-traffic application, almost every single query gets logged.
4. **An Application Loop Bug:** Your application code might be trapped in a loop, running the same slow query thousands of times per minute.
---
cat, nano, or vi, as it can freeze your server's memory. Instead, look at just the first few lines:log_queries_not_using_indexes is ON and you have a busy database, **turn it off** to stop the log explosion:mysqldumpslow to extract the top 5 worst offending queries that are taking up all that space:-s c) and shows the top 5 (-t 5) query patterns causing the bulk of the log size).*mysqldumpslow command** above? (You can paste a small snippet of the top query pattern).
- What are your current **long_query_time** and **log_queries_not_using_indexes** values?
- Is your server currently **running out of disk space** because of this?
oc_filecache table). The log is exploding because **log_queries_not_using_indexes is turned ON**, combined with Nextcloud constantly checking its app data folder.Query_time: 0.089309**: The query is actually very fast, taking only **0.08 seconds** (well below your 2.0-second long_query_time threshold).
- **Full_scan: Yes**: The query is doing a full table scan, checking all 191,623 rows in the oc_filecache table every single time it runs.
- **Why it's logged:** Because log_queries_not_using_indexes = ON, MariaDB is forced to write this fast query to your log file every few hours. On a busy server with multiple users or cron jobs, this fills up gigabytes of text very quickly.
---
/etc/mysql/mariadb.conf.d/50-server.cnf or /etc/my.cnf) and change or add this line under the [mysqld] section:SELECT COUNT(*) FROM oc_filecache WHERE path LIKE 'appdata_...%' uses a wildcard (%) at the end of the string. Nextcloud *should* be using its built-in index on the path column, but sometimes these indexes get corrupted or missing during major Nextcloud upgrades./var/www/nextcloud or /var/www/html):www-data with your web server user if you are using a different one like nginx or apache).*log_queries_not_using_indexes successfully stop the log from growing?
- Do you know the **exact directory path** where your Nextcloud/OwnCloud instance is installed?
- Are you running this instance inside a **Docker container**, or directly on the host system?