Optimizing MySql

Discussion in 'MySQL' started by riteshsanap, Jan 15, 2011.

  1. #1
    I m having a VPS server and it used to eat up lot of RAM due to MySql so i google about optimizing it and i found out so i would like to share it with you also :D

    just edit your my.cnf to the below values
    [mysqld]
    max_connections = 400
    key_buffer = 16M
    myisam_sort_buffer_size = 32M
    join_buffer_size = 1M
    read_buffer_size = 1M
    sort_buffer_size = 2M
    table_cache = 1024
    thread_cache_size = 286
    interactive_timeout = 25
    wait_timeout = 1000
    connect_timeout = 10
    max_allowed_packet = 16M
    max_connect_errors = 10
    query_cache_limit = 1M
    query_cache_size = 16M
    query_cache_type = 1
    tmp_table_size = 16M
    skip-innodb
     
    [mysqld_safe]
    open_files_limit = 8192
     
    [mysqldump]
    quick
    max_allowed_packet = 16M
     
    [myisamchk]
    key_buffer = 32M
    sort_buffer = 32M
    read_buffer = 16M
    write_buffer = 16M
    Code (markup):
    Hope it works with you also i m getting some good results out of it :D
     
    riteshsanap, Jan 15, 2011 IP
  2. diondevelopment

    diondevelopment Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    A bit part of optimization is the table structures themselves. Keep this in mind. Avoid larger types such as TEXT and BLOB. Also use table joins when storing large amounts of values.
     
    diondevelopment, Jan 15, 2011 IP
  3. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #3
    Hmm thanx for that info :p , but i m not at all good with mysql
     
    riteshsanap, Jan 15, 2011 IP
  4. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    MySQL configuration variables lot depend on the amount of RAM available, size of database and size of index. Optimizing your queries is a key part to get better performance out of MySQL.
     
    mwasif, Jan 16, 2011 IP
  5. jenny4pres

    jenny4pres Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The two variables I have found help the most with MySQL are: key_buffer_size and table_cache. However, both involve using more memory (as you crank them up). So the optimal solution for you may be to find suitable values for these two and make sure your tables are properly indexed.
     
    jenny4pres, Jan 27, 2011 IP
  6. Suimme

    Suimme Well-Known Member

    Messages:
    119
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    143
    #6
    Wow this sounds great. Ill try this with my dedicated server, thanks!
     
    Suimme, Jan 28, 2011 IP
  7. jenny4pres

    jenny4pres Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Forgot to also add that query_cache size can also make a difference if you have a queries that have small result sets but query tables with many rows. But again, making it larger increases memory usage.
     
    jenny4pres, Jan 28, 2011 IP
  8. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #8
    Consider reducing wait_timeout to near 50.
     
    mwasif, Jan 28, 2011 IP