Inside the MySQL prompt:
SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file = '/tmp/mariadb_general.log';Or use one-liner from terminal
mysql -u root -e "SET GLOBAL general_log = 'ON'; SET GLOBAL general_log_file = '/tmp/mariadb_general.log';"Turn the log off afterwards:
SET GLOBAL general_log = 'OFF';Check these settings in my.cnf (a MariaDB configuration file):
iniinnodb_buffer_pool_size = 512M # Should be ~70% of available RAM
query_cache_type = 1
query_cache_size = 64M
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 1 # Log queries taking >1sIt'll tell you exactly which queries need attention.
SELECT
table_name,
table_rows,
avg_row_length,
ROUND((data_length + index_length) / 1024 / 1024, 2) AS total_mb
FROM information_schema.tables
WHERE table_name = 'your_table';SELECT
ROUND((data_length + index_length) / 1024 / 1024, 2) AS size_mb
FROM information_schema.tables
WHERE table_name = 'your_table';SELECT
AVG(LENGTH(your_field)) AS avg_your_field,
MAX(LENGTH(your_field)) AS max_your_field
FROM your_table;SELECT
ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 2) AS total_gb
FROM information_schema.tables
WHERE table_schema = DATABASE();SELECT
table_name,
ROUND((data_length + index_length) / 1024 / 1024 / 1024, 2) AS size_gb
FROM information_schema.tables
WHERE table_schema = DATABASE()
ORDER BY size_gb DESC
LIMIT 10;