The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mysql Optimization

Discussion in 'Workarounds and Optimization' started by scorpio18, Jul 27, 2014.

  1. scorpio18

    scorpio18 Registered

    Joined:
    Jul 27, 2014
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi

    I watched this forum about Mysql Optimization , i have a dedicate server and i want to optimize the mysql
    System info:

    CPU
    Intel(R) Xeon(R) CPU W3530 @ 2.80GHz
    Number :
    8
    Cache :
    8192 KB
    Speed :
    2801 MHz
    RAM
    4 x 8192 MB
    Disks
    2 x 2000GB SATA

    MySQLTuner:

    Code:
     >>  MySQLTuner 1.3.0 - Major Hayden <major@mhtx.net>
     >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
     >>  Run with '--help' for additional options and output filtering
    [OK] Logged in using credentials from debian maintenance account.
    [OK] Currently running supported MySQL version 5.5.38-0ubuntu0.14.04.1-log
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
    [--] Data in InnoDB tables: 18M (Tables: 68)
    [--] Data in MyISAM tables: 172B (Tables: 12)
    [--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
    [!!] Total fragmented tables: 68
    
    -------- Security Recommendations  -------------------------------------------
    [OK] All database users have passwords assigned
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 1d 21h 24m 7s (1M q [9.312 qps], 79K conn, TX: 707M, RX: 260M)
    [--] Reads / Writes: 27% / 73%
    [--] Total buffers: 4.3G global + 6.4M per thread (300 max threads)
    [OK] Maximum possible memory usage: 6.2G (19% of installed RAM)
    [OK] Slow queries: 0% (1/1M)
    [OK] Highest usage of available connections: 24% (74/300)
    [OK] Key buffer size / total MyISAM indexes: 10.0M/129.0K
    [!!] Key buffer hit rate: 66.7% (3 cached / 1 reads)
    [OK] Query cache efficiency: 52.7% (341K cached / 647K selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 28K sorts)
    [!!] Joins performed without indexes: 3357
    [OK] Temporary tables created on disk: 0% (592 on disk / 181K total)
    [OK] Thread cache hit rate: 99% (74 created / 79K connections)
    [!!] Table cache hit rate: 5% (153 open / 2K opened)
    [OK] Open file limit used: 0% (73/20K)
    [OK] Table locks acquired immediately: 100% (1M immediate / 1M locks)
    [OK] InnoDB buffer pool / data size: 4.0G/18.2M
    [OK] InnoDB log waits: 0
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Adjust your join queries to always utilize indexes
        Increase table_open_cache gradually to avoid file descriptor limits
        Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
    Variables to adjust:
        join_buffer_size (> 4.0M, or always use indexes with joins)
        table_open_cache (> 5000)

    tuning-primer info:
    Code:
            -- MYSQL PERFORMANCE TUNING PRIMER --
                 - By: Matthew Montgomery -
    
    MySQL Version 5.5.38-0ubuntu0.14.04.1-log x86_64
    
    Uptime = 1 days 21 hrs 31 min 39 sec
    Avg. qps = 9
    Total Questions = 1527865
    Threads Connected = 72
    
    Warning: Server has not been running for at least 48hrs.
    It may not be safe to use these recommendations
    
    To find out more information on how each of these
    runtime variables effects performance visit:
    http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html
    Visit http://www.mysql.com/products/enterprise/advisors.html
    for info about MySQL's Enterprise Monitoring and Advisory Service
    
    SLOW QUERIES
    The slow query log is enabled.
    Current long_query_time = 10.000000 sec.
    You have 1 out of 1527887 that take longer than 10.000000 sec. to complete
    Your long_query_time seems to be fine
    
    BINARY UPDATE LOG
    The binary update log is NOT enabled.
    You will not be able to do point in time recovery
    See http://dev.mysql.com/doc/refman/5.5/en/point-in-time-recovery.html
    
    WORKER THREADS
    Current thread_cache_size = 384
    Current threads_cached = 2
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine
    
    MAX CONNECTIONS
    Current max_connections = 300
    Current threads_connected = 72
    Historic max_used_connections = 74
    The number of used connections is 24% of the configured maximum.
    Your max_connections variable seems to be fine.
    
    INNODB STATUS
    Current InnoDB index space = 24 M
    Current InnoDB data space = 18 M
    Current InnoDB buffer pool free = 98 %
    Current innodb_buffer_pool_size = 4.00 G
    Depending on how much space your innodb indexes take up it may be safe
    to increase this value to up to 2 / 3 of total system memory
    
    MEMORY USAGE
    Max Memory Ever Allocated : 4.76 G
    Configured Max Per-thread Buffers : 1.88 G
    Configured Max Global Buffers : 4.29 G
    Configured Max Memory Limit : 6.18 G
    Physical Memory : 31.47 G
    Max memory limit seem to be within acceptable norms
    
    KEY BUFFER
    Current MyISAM index space = 138 K
    Current key_buffer_size = 10 M
    Key cache miss rate is 1 : 3
    Key buffer free ratio = 80 %
    Your key_buffer_size seems to be fine
    
    QUERY CACHE
    Query cache is enabled
    Current query_cache_size = 256 M
    Current query_cache_used = 221 K
    Current query_cache_limit = 2 M
    Current Query cache Memory fill ratio = .08 %
    Current query_cache_min_res_unit = 4 K
    Your query_cache_size seems to be too high.
    Perhaps you can use these resources elsewhere
    MySQL won't cache query results that are larger than query_cache_limit in size
    
    SORT OPERATIONS
    Current sort_buffer_size = 2 M
    Current read_rnd_buffer_size = 128 K
    Sort buffer seems to be fine
    
    JOINS
    Current join_buffer_size = 4.00 M
    You have had 3365 queries where a join could not use an index properly
    join_buffer_size >= 4 M
    This is not advised
    You should enable "log-queries-not-using-indexes"
    Then look for non indexed joins in the slow query log.
    
    OPEN FILES LIMIT
    Current open_files_limit = 20310 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine
    
    TABLE CACHE
    Current table_open_cache = 5000 tables
    Current table_definition_cache = 400 tables
    You have a total of 121 tables
    You have 153 open tables.
    The table_cache value seems to be fine
    
    TEMP TABLES
    Current max_heap_table_size = 16 M
    Current tmp_table_size = 16 M
    Of 181556 temp tables, 0% were created on disk
    Created disk tmp tables ratio seems fine
    
    TABLE SCANS
    Current read_buffer_size = 128 K
    Current table scan ratio = 522 : 1
    read_buffer_size seems to be fine
    
    TABLE LOCKING
    Current Lock Wait ratio = 0 : 1528152
    Your table locking seems to be fine
    
    What settings do you suggest to make?
     
  2. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    As the tuning-primer script says:
    "Warning: Server has not been running for at least 48hrs.
    It may not be safe to use these recommendations
    "
     
  3. scorpio18

    scorpio18 Registered

    Joined:
    Jul 27, 2014
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner

    tuning-primer info after 48hrs

    Code:
            -- MYSQL PERFORMANCE TUNING PRIMER --
                 - By: Matthew Montgomery -
    
    MySQL Version 5.5.38-0ubuntu0.14.04.1-log x86_64
    
    Uptime = 2 days 0 hrs 18 min 37 sec
    Avg. qps = 9
    Total Questions = 1651070
    Threads Connected = 68
    
    Server has been running for over 48hrs.
    It should be safe to follow these recommendations
    
    To find out more information on how each of these
    runtime variables effects performance visit:
    http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html
    Visit http://www.mysql.com/products/enterprise/advisors.html
    for info about MySQL's Enterprise Monitoring and Advisory Service
    
    SLOW QUERIES
    The slow query log is enabled.
    Current long_query_time = 10.000000 sec.
    You have 1 out of 1651091 that take longer than 10.000000 sec. to complete
    Your long_query_time seems to be fine
    
    BINARY UPDATE LOG
    The binary update log is NOT enabled.
    You will not be able to do point in time recovery
    See http://dev.mysql.com/doc/refman/5.5/en/point-in-time-recovery.html
    
    WORKER THREADS
    Current thread_cache_size = 384
    Current threads_cached = 15
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine
    
    MAX CONNECTIONS
    Current max_connections = 300
    Current threads_connected = 68
    Historic max_used_connections = 83
    The number of used connections is 27% of the configured maximum.
    Your max_connections variable seems to be fine.
    
    INNODB STATUS
    Current InnoDB index space = 25 M
    Current InnoDB data space = 18 M
    Current InnoDB buffer pool free = 98 %
    Current innodb_buffer_pool_size = 4.00 G
    Depending on how much space your innodb indexes take up it may be safe
    to increase this value to up to 2 / 3 of total system memory
    
    MEMORY USAGE
    Max Memory Ever Allocated : 4.82 G
    Configured Max Per-thread Buffers : 1.88 G
    Configured Max Global Buffers : 4.29 G
    Configured Max Memory Limit : 6.18 G
    Physical Memory : 31.47 G
    Max memory limit seem to be within acceptable norms
    
    KEY BUFFER
    Current MyISAM index space = 138 K
    Current key_buffer_size = 10 M
    Key cache miss rate is 1 : 3
    Key buffer free ratio = 80 %
    Your key_buffer_size seems to be fine
    
    QUERY CACHE
    Query cache is enabled
    Current query_cache_size = 256 M
    Current query_cache_used = 338 K
    Current query_cache_limit = 2 M
    Current Query cache Memory fill ratio = .12 %
    Current query_cache_min_res_unit = 4 K
    Your query_cache_size seems to be too high.
    Perhaps you can use these resources elsewhere
    MySQL won't cache query results that are larger than query_cache_limit in size
    
    SORT OPERATIONS
    Current sort_buffer_size = 2 M
    Current read_rnd_buffer_size = 128 K
    Sort buffer seems to be fine
    
    JOINS
    Current join_buffer_size = 4.00 M
    You have had 3570 queries where a join could not use an index properly
    join_buffer_size >= 4 M
    This is not advised
    You should enable "log-queries-not-using-indexes"
    Then look for non indexed joins in the slow query log.
    
    OPEN FILES LIMIT
    Current open_files_limit = 20310 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine
    
    TABLE CACHE
    Current table_open_cache = 5000 tables
    Current table_definition_cache = 400 tables
    You have a total of 138 tables
    You have 179 open tables.
    The table_cache value seems to be fine
    
    TEMP TABLES
    Current max_heap_table_size = 16 M
    Current tmp_table_size = 16 M
    Of 194879 temp tables, 0% were created on disk
    Created disk tmp tables ratio seems fine
    
    TABLE SCANS
    Current read_buffer_size = 128 K
    Current table scan ratio = 594 : 1
    read_buffer_size seems to be fine
    
    TABLE LOCKING
    Current Lock Wait ratio = 0 : 1651376
    Your table locking seems to be fine
    mysqltuner:

    Code:
     >>  MySQLTuner 1.3.0 - Major Hayden <major@mhtx.net>
     >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
     >>  Run with '--help' for additional options and output filtering
    [OK] Logged in using credentials from debian maintenance account.
    [OK] Currently running supported MySQL version 5.5.38-0ubuntu0.14.04.1-log
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
    [--] Data in MyISAM tables: 172B (Tables: 12)
    [--] Data in InnoDB tables: 18M (Tables: 85)
    [--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
    [!!] Total fragmented tables: 85
    
    -------- Security Recommendations  -------------------------------------------
    [OK] All database users have passwords assigned
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 2d 0h 20m 32s (1M q [9.496 qps], 86K conn, TX: 763M, RX: 282M)
    [--] Reads / Writes: 27% / 73%
    [--] Total buffers: 4.3G global + 6.4M per thread (300 max threads)
    [OK] Maximum possible memory usage: 6.2G (19% of installed RAM)
    [OK] Slow queries: 0% (1/1M)
    [OK] Highest usage of available connections: 27% (83/300)
    [OK] Key buffer size / total MyISAM indexes: 10.0M/129.0K
    [!!] Key buffer hit rate: 66.7% (3 cached / 1 reads)
    [OK] Query cache efficiency: 53.0% (373K cached / 705K selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 31K sorts)
    [!!] Joins performed without indexes: 3572
    [OK] Temporary tables created on disk: 0% (664 on disk / 195K total)
    [OK] Thread cache hit rate: 99% (83 created / 86K connections)
    [!!] Table cache hit rate: 5% (179 open / 2K opened)
    [OK] Open file limit used: 0% (73/20K)
    [OK] Table locks acquired immediately: 100% (1M immediate / 1M locks)
    [OK] InnoDB buffer pool / data size: 4.0G/18.6M
    [OK] InnoDB log waits: 0
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Adjust your join queries to always utilize indexes
        Increase table_open_cache gradually to avoid file descriptor limits
        Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
    Variables to adjust:
        join_buffer_size (> 4.0M, or always use indexes with joins)
        table_open_cache (> 5000)
    
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Are there any issues with MySQL overall (e.g. running slow)? Or, are you simply trying to improve it's speed as much as possible. You could try modifying the "Variables to adjust" in your /etc/my.cnf file as listed in the output of the tuner script.

    Thank you.
     
Loading...

Share This Page