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 question - query_cache_size > 512M

Discussion in 'Workarounds and Optimization' started by rwagener11, Feb 18, 2011.

  1. rwagener11

    rwagener11 Member

    Joined:
    Jun 7, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Ok I am not sure where to go from here. It says I should increase the query_cache_size over 512 but then states it might do worse if over 128M. Any ideas? Here is all my info.

    Code:
     >>  MySQLTuner 1.1.2 - Major Hayden <major@mhtx.net>
     >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
     >>  Run with '--help' for additional options and output filtering
    
    -------- General Statistics --------------------------------------------------
    [--] Skipped version check for MySQLTuner script
    [OK] Currently running supported MySQL version 5.1.54
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
    [--] Data in MyISAM tables: 439M (Tables: 333)
    [--] Data in InnoDB tables: 457M (Tables: 30)
    [--] Data in MEMORY tables: 0B (Tables: 1)
    [!!] Total fragmented tables: 52
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 1d 19h 38m 26s (43M q [274.977 qps], 3M conn, TX: 50B, RX: 4B)
    [--] Reads / Writes: 82% / 18%
    [--] Total buffers: 1.9G global + 2.7M per thread (2000 max threads)
    [OK] Maximum possible memory usage: 7.2G (46% of installed RAM)
    [OK] Slow queries: 0% (67/43M)
    [OK] Highest usage of available connections: 24% (494/2000)
    [OK] Key buffer size / total MyISAM indexes: 128.0M/172.5M
    [OK] Key buffer hit rate: 99.5% (24M cached / 124K reads)
    [OK] Query cache efficiency: 86.4% (28M cached / 33M selects)
    [!!] Query cache prunes per day: 426908
    [OK] Sorts requiring temporary tables: 0% (55 temp sorts / 558K sorts)
    [!!] Temporary tables created on disk: 34% (94K on disk / 272K total)
    [OK] Thread cache hit rate: 98% (55K created / 3M connections)
    [!!] Table cache hit rate: 17% (736 open / 4K opened)
    [OK] Open file limit used: 9% (991/10K)
    [OK] Table locks acquired immediately: 99% (5M immediate / 5M locks)
    [OK] InnoDB data size / buffer pool: 457.5M/1000.0M
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Enable the slow query log to troubleshoot bad queries
        Increasing the query_cache size over 128M may reduce performance
        Temporary table size is already large - reduce result set size
        Reduce your SELECT DISTINCT queries without LIMIT clauses
        Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
        query_cache_size (> 512M) [see warning above]
        table_cache (> 2048)
    
    my.cnf
    Code:
    [mysqld]
    max_connections=2000
    
    key_buffer_size=128M
    table_cache=2048
    thread_cache=12
    
    query_cache_size=512M
    
    tmp_table_size=256M
    max_heap_table_size=256M
    
    query_cache_min_res_unit=1024
    table_definition_cache=400
    wait_timeout=60
    thread_cache_size=30
    
    innodb_buffer_pool_size=1000M
    
    Here is what tuning-primer says

    Code:
            -- MYSQL PERFORMANCE TUNING PRIMER --
                 - By: Matthew Montgomery -
    
    MySQL Version 5.1.54 x86_64
    
    Uptime = 1 days 19 hrs 42 min 31 sec
    Avg. qps = 274
    Total Questions = 43264050
    Threads Connected = 10
    
    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.1/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 NOT enabled.
    Current long_query_time = 10.000000 sec.
    You have 67 out of 43264429 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.1/en/point-in-time-recovery.html
    
    WORKER THREADS
    Current thread_cache_size = 30
    Current threads_cached = 29
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine
    
    MAX CONNECTIONS
    Current max_connections = 2000
    Current threads_connected = 3
    Historic max_used_connections = 494
    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 = 214 M
    Current InnoDB data space = 457 M
    Current InnoDB buffer pool free = 35 %
    Current innodb_buffer_pool_size = 1000 M
    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 : 2.93 G
    Configured Max Per-thread Buffers : 5.37 G
    Configured Max Global Buffers : 1.60 G
    Configured Max Memory Limit : 6.97 G
    Physical Memory : 15.67 G
    Max memory limit seem to be within acceptable norms
    
    KEY BUFFER
    Current MyISAM index space = 172 M
    Current key_buffer_size = 128 M
    Key cache miss rate is 1 : 200
    Key buffer free ratio = 70 %
    Your key_buffer_size seems to be fine
    
    QUERY CACHE
    Query cache is enabled
    Current query_cache_size = 512 M
    Current query_cache_used = 453 M
    Current query_cache_limit = 1 M
    Current Query cache Memory fill ratio = 88.55 %
    Current query_cache_min_res_unit = 1 K
    However, 777744 queries have been removed from the query cache due to lack of memory
    Perhaps you should raise query_cache_size
    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 = 256 K
    Sort buffer seems to be fine
    
    JOINS
    Current join_buffer_size = 132.00 K
    You have had 8 queries where a join could not use an index properly
    You should enable "log-queries-not-using-indexes"
    Then look for non indexed joins in the slow query log.
    If you are unable to optimize your queries you may want to increase your
    join_buffer_size to accommodate larger joins in one pass.
    
    Note! This script will still suggest raising the join_buffer_size when
    ANY joins not using indexes are found.
    
    OPEN FILES LIMIT
    Current open_files_limit = 10000 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 = 2048 tables
    Current table_definition_cache = 400 tables
    You have a total of 387 tables
    You have 736 open tables.
    The table_cache value seems to be fine
    
    TEMP TABLES
    Current max_heap_table_size = 256 M
    Current tmp_table_size = 256 M
    Of 178551 temp tables, 34% were created on disk
    Perhaps you should increase your tmp_table_size and/or max_heap_table_size
    to reduce the number of disk-based temporary tables
    Note! BLOB and TEXT columns are not allow in memory tables.
    If you are using these columns raising these values might not impact your
    ratio of on disk temp tables.
    
    TABLE SCANS
    Current read_buffer_size = 128 K
    Current table scan ratio = 91 : 1
    read_buffer_size seems to be fine
    
    TABLE LOCKING
    Current Lock Wait ratio = 1 : 53981
    Your table locking seems to be fine
    
     
  2. LinuxTechie

    LinuxTechie Well-Known Member

    Joined:
    Jan 22, 2011
    Messages:
    502
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hello,

    Your my.cnf is having the below given value.

    query_cache_size=512M

    This is the reason why you received the warning. It is better you reset it to 128M.
     
  3. rwagener11

    rwagener11 Member

    Joined:
    Jun 7, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Ok thanks. cPtechie. After I change that back. Should I just ignore the message to increase the query_cache_size?
     
  4. LinuxTechie

    LinuxTechie Well-Known Member

    Joined:
    Jan 22, 2011
    Messages:
    502
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hello,

    After editing my.cnf please make sure to restart mysql service. After 24 - 48 hours please re - run the tuner and paste the results here. So that I can guide you on that.
     
  5. rwagener11

    rwagener11 Member

    Joined:
    Jun 7, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    will do... just made the change and it's live. eventually I will not need help. until then I appreciate it!
     
  6. LinuxTechie

    LinuxTechie Well-Known Member

    Joined:
    Jan 22, 2011
    Messages:
    502
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hello,

    Okay! Thank you :)
     
  7. rwagener11

    rwagener11 Member

    Joined:
    Jun 7, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Here is the latest and greatest.

     
  8. LinuxTechie

    LinuxTechie Well-Known Member

    Joined:
    Jan 22, 2011
    Messages:
    502
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hello,

    I thinks you can increase the query_cache_size to 256M.

    I have also noted some recommendations.

    >> Run "FLUSH QUERY CACHE" periodically to defragment the query cache memory,
    >> The number of used connections is 4% of the configured maximum. Lowering max_connections could help to avoid an over-allocation of memory. You are using less than 10% of your configured max_connections. So you can also lower the max_connections=2000 to 200.

    Let me know if you need any other clarifications.
     
  9. bhanuprasad1981

    bhanuprasad1981 Well-Known Member

    Joined:
    Aug 5, 2008
    Messages:
    222
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    can i know how can we do "flush query cache" ??
     
  10. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page