Cloud House Technologies Logo
CloudHouse Technologies
HomeServicesProjectsBlogAbout UsCareersContact UsLogin
    Cloud House Technologies Logo
    CloudHouse Technologies
    HomeServicesProjectsBlogAbout UsCareersContact UsLogin

    Fix Slow MySQL/MariaDB Queries on DirectAdmin: Performance Tuning Guide

    Priya

    Content Writer & Researcher

    Last Updated: 10 July 2026
    🖥️

    Stop MySQL Slowdowns From Killing Your DirectAdmin Server's Performance

    CloudHouse's server team tunes MariaDB/MySQL configuration, analyses slow query logs, and monitors database performance 24/7 on DirectAdmin servers — so your sites stay fast under any load.

    🔧 Book Free DiagnosisCall NowWhatsApp
    🖥️12,400+PCs Fixed
    ⭐4.9★Google Rating
    ⚡<15 minAvg. Response
    🛡️ISO 27001Certified

    On DirectAdmin hosting servers, slow MySQL or MariaDB query performance is one of the most common root causes of high CPU load, PHP timeouts, and sluggish WordPress or e-commerce sites. The default MariaDB configuration that ships with most DirectAdmin installations is tuned conservatively — it works on minimal RAM but leaves significant performance on the table for servers with 2 GB or more. This guide shows you how to diagnose slow queries with the slow query log, use mysqltuner to identify bottlenecks, and apply the key configuration changes to my.cnf that will have the biggest impact.

    💡 None of these worked? Skip the guesswork.

    Get Expert Help →

    Step 1: Enable the Slow Query Log in DirectAdmin

    Before tuning anything, you need data. The slow query log records every query that takes longer than a configurable threshold, giving you a precise list of the queries causing performance problems.

    1Locate the MariaDB/MySQL configuration file

    On DirectAdmin servers, the main configuration file is typically at:

    /etc/my.cnf

    Some installations split configuration into /etc/mysql/conf.d/. Check both locations.

    2Add slow query log settings to my.cnf

    Open the file as root and add these lines under the [mysqld] section:

    [mysqld]
    slow_query_log = 1
    slow_query_log_file = /var/log/mysql-slow.log
    long_query_time = 1
    log_queries_not_using_indexes = 1

    long_query_time = 1 records any query taking more than 1 second. On a heavily loaded server, start at 2 seconds to reduce log volume. The log_queries_not_using_indexes flag is especially valuable — full table scans on large tables often take milliseconds but become catastrophic as data grows.

    3Restart MariaDB to apply the changes
    systemctl restart mariadb

    Or via DirectAdmin service manager: DirectAdmin → Advanced → Service Monitor → MariaDB/MySQL → Restart.

    4Generate some traffic and read the log

    Let the server run under normal load for 10-15 minutes, then read the slow query log:

    tail -100 /var/log/mysql-slow.log

    Look for queries with high Query_time values and tables appearing in EXPLAIN outputs without an index being used.

    1Download and run mysqltuner
    wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
    perl mysqltuner.pl --host 127.0.0.1

    It will prompt for the root password. You can also pass it with --user root --pass yourpassword.

    2Read the Recommendations section

    The output is divided into sections. Focus on the lines marked [!!] — these are warnings requiring attention. Common findings on stock DirectAdmin installations include:

    • innodb_buffer_pool_size is set too low relative to available RAM
    • High thread creation rate (thread_cache_size too small)
    • Table cache too small (table_open_cache)
    • Many slow queries logged without indexes being used
    1Check current innodb_buffer_pool_size
    mysql -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_size';"

    The default is often 128 MB — far too small for a server with 4+ GB of RAM running multiple WordPress sites.

    2Set innodb_buffer_pool_size to 50-70% of available RAM

    On a dedicated server or VPS, this is the most impactful single change you can make. For a 4 GB RAM server:

    [mysqld]
    innodb_buffer_pool_size = 2G

    For an 8 GB RAM server, set it to 5-6 GB. On shared hosting servers where DirectAdmin manages multiple accounts, use 40-50% to leave headroom for Apache, PHP-FPM, and the OS.

    3Enable multiple buffer pool instances for high-concurrency servers

    For servers with 8+ GB buffer pool size, use multiple instances to reduce lock contention:

    innodb_buffer_pool_instances = 4

    Each instance should be at least 1 GB. The total pool size divides evenly across instances.

    1Check thread creation rate
    mysql -e "SHOW STATUS LIKE 'Threads_created';"
    mysql -e "SHOW STATUS LIKE 'Connections';"

    If Threads_created is close to Connections, threads are being created for every connection — the cache is too small or empty.

    2Set thread_cache_size
    [mysqld]
    thread_cache_size = 32

    For busy DirectAdmin servers with many cPanel-style sites, 32-64 is appropriate.

    3Tune max_connections

    The default max_connections is often 151, which can be too low on busy DirectAdmin servers:

    max_connections = 300

    Watch SHOW STATUS LIKE 'Max_used_connections' — if this is approaching your max_connections limit, you'll see connection refused errors in PHP/WordPress logs.

    1Increase table_open_cache

    Each table that's opened requires a file descriptor. The table_open_cache controls how many open table instances MariaDB maintains in memory:

    table_open_cache = 2000
    table_definition_cache = 1400
    2Increase InnoDB log file size

    Larger InnoDB redo logs improve write performance on busy servers but increase crash recovery time:

    innodb_log_file_size = 256M

    Note: Changing innodb_log_file_size requires a clean shutdown of MariaDB. Stop the service, delete the old log files (/var/lib/mysql/ib_logfile*), then start MariaDB — it will recreate them at the new size.

    Step 6: Apply the Complete Optimised my.cnf Configuration

    Here is a consolidated recommended configuration for a DirectAdmin server with 4 GB RAM running typical WordPress and PHP applications. Add these under the [mysqld] section:

    [mysqld]
    # InnoDB performance
    innodb_buffer_pool_size = 2G
    innodb_buffer_pool_instances = 2
    innodb_log_file_size = 256M
    innodb_flush_method = O_DIRECT
    innodb_flush_log_at_trx_commit = 2
    
    # Connection handling
    max_connections = 250
    thread_cache_size = 32
    table_open_cache = 2000
    table_definition_cache = 1400
    
    # Query cache (disable on MariaDB 10.3+)
    query_cache_type = 0
    query_cache_size = 0
    
    # Slow query logging
    slow_query_log = 1
    slow_query_log_file = /var/log/mysql-slow.log
    long_query_time = 1
    log_queries_not_using_indexes = 1
    
    # Temporary tables
    tmp_table_size = 128M
    max_heap_table_size = 128M

    Note on innodb_flush_log_at_trx_commit = 2: This reduces disk I/O by flushing the log to disk once per second rather than on every commit. On a web hosting server, the performance gain is significant — the only risk is losing up to 1 second of transactions in a hard crash, acceptable for most hosting workloads.

    Note on query_cache_type = 0: The MySQL query cache was removed entirely in MySQL 8.0 and is effectively deprecated in MariaDB 10.3+. It causes mutex contention on busy servers and should be disabled.

    Step 7: Monitor After Tuning

    After restarting MariaDB with the new configuration, monitor these metrics over the next 24 hours:

    # Buffer pool hit rate (should be > 99%)
    mysql -e "SHOW STATUS LIKE 'Innodb_buffer_pool_reads%';"
    
    # Thread cache efficiency
    mysql -e "SHOW STATUS LIKE 'Threads_created';"
    
    # Check for max connection saturation
    mysql -e "SHOW STATUS LIKE 'Max_used_connections';"
    
    # Check slow query log for improvements
    wc -l /var/log/mysql-slow.log

    For ongoing DirectAdmin server performance monitoring and database tuning, CloudHouse's managed server service includes MySQL/MariaDB performance reviews, slow query analysis, and proactive configuration tuning.

    FAQs

    Conclusion

    Fixing slow MariaDB/MySQL performance on a DirectAdmin server starts with enabling the slow query log to find problem queries, then running mysqltuner to identify configuration gaps. The highest-impact changes are almost always setting innodb_buffer_pool_size to 50-70% of available RAM, enabling thread caching, and disabling the legacy query cache. Apply the configuration changes incrementally, restart MariaDB, and monitor buffer pool hit rates and slow query log volume to confirm improvements. For DirectAdmin servers where database performance is critical and changes need to be made safely under load, CloudHouse's managed server team handles MariaDB tuning, monitoring, and ongoing optimisation.

    Get the Free Linux Server Admin Cheatsheet (PDF)

    Essential commands for server management, networking, and troubleshooting — all on one printable page.

    Running Linux servers? Let us manage them for you.

    Our Managed Linux Server plans cover updates, security hardening, monitoring, and 24/7 incident response — so your servers stay up and your team stays focused.

    • Proactive OS patching and security updates
    • 24×7 monitoring with instant alerting
    • Backup configuration and disaster recovery
    • Dedicated Linux engineers on call
    See Pricing Plans →

    What our customers say

    “Our production server went down at 2 AM. CloudHouse had it back online in under 20 minutes. Incredible response time.”

    Arun S.

    CTO, SaaS Startup

    “They migrated our entire infrastructure from Ubuntu 18 to 22 with zero downtime. Couldn't have asked for better.”

    Deepak N.

    DevOps Lead

    Frequently Asked Questions

    Edit /etc/my.cnf as root and add under [mysqld]: slow_query_log = 1, slow_query_log_file = /var/log/mysql-slow.log, long_query_time = 1. Then restart MariaDB with systemctl restart mariadb. Queries taking longer than 1 second will be logged. Read the log with tail -100 /var/log/mysql-slow.log or use mysqldumpslow to sort by worst offenders.

    Book your free 15-minute diagnosis

    A certified technician will call you back within 15 minutes during business hours.

    Share this article

    Leave a Comment

    Comments (0)

    Loading comments...

    Is Slow MySQL Grinding Your DirectAdmin Server to a Halt?

    High CPU load, PHP timeouts, and slow WordPress sites on DirectAdmin are often a database configuration problem — not a hardware problem. CloudHouse Technologies audits and tunes MariaDB performance for DirectAdmin hosting servers. Get a performance review today.

    Call Now — FreeWhatsApp Us

    Why CloudHouse?

    • ISO 27001:2022 certified
    • 12,400+ devices supported
    • 4.9★ on Google
    • Sub-15-minute response

    CloudHouse Technologies

    Innovative cloud solutions for modern businesses. We deliver cutting-edge technology with exceptional service.

    Contact Us

    CloudHouse Technologies Pvt.Ltd
    Special Economic Zone(SEZ),
    Infopark Thirissur,4B-15,
    Indeevaram,Nalukettu Road,
    Koratty, Kerala, India-680308
    0480-27327360
    info@cloudhousetechnologies.com

    Quick Links

    • Our Services
    • Gold Loan Software
    • About Us
    • Contact
    • Terms and Conditions
    • Privacy Policy
    ISO27001:2022
    Certified

    © 2026 CloudHouse Technologies Pvt.Ltd. All rights reserved.

    Back to top