{"id":2445,"date":"2010-02-11T02:50:54","date_gmt":"2010-02-11T07:50:54","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=2445"},"modified":"2010-02-11T02:50:54","modified_gmt":"2010-02-11T07:50:54","slug":"mysql-tuning-primer","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/","title":{"rendered":"MYSQL tuning-primer"},"content":{"rendered":"<p>MySQL Performance Tuning Primer Script<\/p>\n<p>This script takes information from &#8220;SHOW STATUS LIKE&#8230;&#8221; and &#8220;SHOW VARIABLES LIKE&#8230;&#8221;<br \/>\nto produce sane recommendations for tuning server variables.<br \/>\nIt is compatible with all versions of MySQL 3.23 and higher (including 5.1).<\/p>\n<p>Currently it handles recommendations for the following:<br \/>\n# Slow Query Log<br \/>\n# Max Connections<br \/>\n# Worker Threads<br \/>\n# Key Buffer<br \/>\n# Query Cache<br \/>\n# Sort Buffer<br \/>\n# Joins<br \/>\n# Temp Tables<br \/>\n# Table (Open &#038; Definition) Cache<br \/>\n# Table Locking<br \/>\n# Table Scans (read_buffer)<br \/>\n# Innodb Status<\/p>\n<p>Recent Changes<br \/>\n# Correct awk display error which formats integers > 4294967296 in scientific notation.<br \/>\n&#8211; Was manifest in MEMORY USAGE section where total system RAM > 4GB.<br \/>\n# Fixed rounding error where mysql will lose 4K from the join_buffer_size value.<br \/>\n&#8211; Other values may have the same issue but are not yet reported<br \/>\n# Added support for FreeBSD and MacOS (thanks Sam and Geert)<br \/>\n# Added support for Solaris<br \/>\n# Changed how system memory is derived on Linux.<br \/>\n&#8211; Use \/proc\/meminfo vs free -b and avoid inclusion of swap space.<br \/>\n# Include note warning of instability when key_buffer_size > 4GB in versions 5.0.51 and lower<\/p>\n<p>To get the tuning-primer.sh run the following from the command line<br \/>\n<code>wget -O \/scripts\/tuning-primer.sh http:\/\/day32.com\/MySQL\/tuning-primer.sh<\/code><br \/>\nand then execute the script like so<br \/>\n<code><br \/>\nroot@host [~]# sh \/scripts\/tuning-primer.sh <\/p>\n<p>\t-- MYSQL PERFORMANCE TUNING PRIMER --<br \/>\n\t     - By: Matthew Montgomery -<\/p>\n<p>MySQL Version 5.0.87-community i686<\/p>\n<p>Uptime = 35 days 4 hrs 24 min 23 sec<br \/>\nAvg. qps = 0<br \/>\nTotal Questions = 953824<br \/>\nThreads Connected = 1<\/p>\n<p>Server has been running for over 48hrs.<br \/>\nIt should be safe to follow these recommendations<\/p>\n<p>To find out more information on how each of these<br \/>\nruntime variables effects performance visit:<br \/>\nhttp:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/server-system-variables.html<br \/>\nVisit http:\/\/www.mysql.com\/products\/enterprise\/advisors.html<br \/>\nfor info about MySQL's Enterprise Monitoring and Advisory Service<\/p>\n<p>SLOW QUERIES<br \/>\nThe slow query log is NOT enabled.<br \/>\nCurrent long_query_time = 10 sec.<br \/>\nYou have 0 out of 953845 that take longer than 10 sec. to complete<br \/>\nYour long_query_time seems to be fine<\/p>\n<p>BINARY UPDATE LOG<br \/>\nThe binary update log is NOT enabled.<br \/>\nYou will not be able to do point in time recovery<br \/>\nSee http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/point-in-time-recovery.html<\/p>\n<p>WORKER THREADS<br \/>\nCurrent thread_cache_size = 0<br \/>\nCurrent threads_cached = 0<br \/>\nCurrent threads_per_sec = 1<br \/>\nHistoric threads_per_sec = 0<br \/>\nYour thread_cache_size is fine<\/p>\n<p>MAX CONNECTIONS<br \/>\nCurrent max_connections = 150<br \/>\nCurrent threads_connected = 1<br \/>\nHistoric max_used_connections = 13<br \/>\nThe number of used connections is 8% of the configured maximum.<br \/>\nYou are using less than 10% of your configured max_connections.<br \/>\nLowering max_connections could help to avoid an over-allocation of memory<br \/>\nSee \"MEMORY USAGE\" section to make sure you are not over-allocating<\/p>\n<p>No InnoDB Support Enabled!<\/p>\n<p>MEMORY USAGE<br \/>\nMax Memory Ever Allocated : 110 M<br \/>\nConfigured Max Per-thread Buffers : 234 M<br \/>\nConfigured Max Global Buffers : 90 M<br \/>\nConfigured Max Memory Limit : 324 M<br \/>\nPhysical Memory : 512 M<br \/>\nMax memory limit seem to be within acceptable norms<\/p>\n<p>KEY BUFFER<br \/>\nCurrent MyISAM index space = 1 M<br \/>\nCurrent key_buffer_size = 16 M<br \/>\nKey cache miss rate is 1 : 326<br \/>\nKey buffer free ratio = 85 %<br \/>\nYour key_buffer_size seems to be fine<\/p>\n<p>QUERY CACHE<br \/>\nQuery cache is enabled<br \/>\nCurrent query_cache_size = 64 M<br \/>\nCurrent query_cache_used = 715 K<br \/>\nCurrent query_cache_limit = 1 M<br \/>\nCurrent Query cache Memory fill ratio = 1.09 %<br \/>\nCurrent query_cache_min_res_unit = 4 K<br \/>\nQuery Cache is 24 % fragmented<br \/>\nRun \"FLUSH QUERY CACHE\" periodically to defragment the query cache memory<br \/>\nIf you have many small queries lower 'query_cache_min_res_unit' to reduce fragmentation.<br \/>\nYour query_cache_size seems to be too high.<br \/>\nPerhaps you can use these resources elsewhere<br \/>\nMySQL won't cache query results that are larger than query_cache_limit in size<\/p>\n<p>SORT OPERATIONS<br \/>\nCurrent sort_buffer_size = 512 K<br \/>\nCurrent read_rnd_buffer_size = 512 K<br \/>\nSort buffer seems to be fine<\/p>\n<p>JOINS<br \/>\nCurrent join_buffer_size = 132.00 K<br \/>\nYou have had 0 queries where a join could not use an index properly<br \/>\nYour joins seem to be using indexes properly<\/p>\n<p>OPEN FILES LIMIT<br \/>\nCurrent open_files_limit = 4096 files<br \/>\nThe open_files_limit should typically be set to at least 2x-3x<br \/>\nthat of table_cache if you have heavy MyISAM usage.<br \/>\nYour open_files_limit value seems to be fine<\/p>\n<p>TABLE CACHE<br \/>\nCurrent table_cache value = 128 tables<br \/>\nYou have a total of 81 tables<br \/>\nYou have 128 open tables.<br \/>\nCurrent table_cache hit rate is 26%<br \/>\n, while 100% of your table cache is in use<br \/>\nYou should probably increase your table_cache<\/p>\n<p>TEMP TABLES<br \/>\nCurrent max_heap_table_size = 16 M<br \/>\nCurrent tmp_table_size = 32 M<br \/>\nOf 35543 temp tables, 36% were created on disk<br \/>\nEffective in-memory tmp_table_size is limited to max_heap_table_size.<br \/>\nPerhaps you should increase your tmp_table_size and\/or max_heap_table_size<br \/>\nto reduce the number of disk-based temporary tables<br \/>\nNote! BLOB and TEXT columns are not allow in memory tables.<br \/>\nIf you are using these columns raising these values might not impact your<br \/>\nratio of on disk temp tables.<\/p>\n<p>TABLE SCANS<br \/>\nCurrent read_buffer_size = 256 K<br \/>\nCurrent table scan ratio = 12 : 1<br \/>\nread_buffer_size seems to be fine<\/p>\n<p>TABLE LOCKING<br \/>\nCurrent Lock Wait ratio = 1 : 1774<br \/>\nYou may benefit from selective use of InnoDB.<br \/>\nIf you have long running SELECT's against MyISAM tables and perform<br \/>\nfrequent updates consider setting 'low_priority_updates=1'<br \/>\nIf you have a high concurrency of inserts on Dynamic row-length tables<br \/>\nconsider setting 'concurrent_insert=2'.<br \/>\n<\/code><\/p>\n<p>From <a href=\"http:\/\/day32.com\/MySQL\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/day32.com\/MySQL\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL Performance Tuning Primer Script This script takes information from &#8220;SHOW STATUS LIKE&#8230;&#8221; and &#8220;SHOW VARIABLES LIKE&#8230;&#8221; to produce sane recommendations for tuning server variables. It is compatible with all versions of MySQL 3.23 and higher (including 5.1). Currently it handles recommendations for the following: # Slow Query Log # Max Connections # Worker Threads&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2445","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MYSQL tuning-primer - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MYSQL tuning-primer - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"MySQL Performance Tuning Primer Script This script takes information from &#8220;SHOW STATUS LIKE&#8230;&#8221; and &#8220;SHOW VARIABLES LIKE&#8230;&#8221; to produce sane recommendations for tuning server variables. It is compatible with all versions of MySQL 3.23 and higher (including 5.1). Currently it handles recommendations for the following: # Slow Query Log # Max Connections # Worker Threads... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2010-02-11T07:50:54+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"MYSQL tuning-primer\",\"datePublished\":\"2010-02-11T07:50:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/\"},\"wordCount\":197,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/\",\"name\":\"MYSQL tuning-primer - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2010-02-11T07:50:54+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/mysql-tuning-primer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MYSQL tuning-primer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MYSQL tuning-primer - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/","og_locale":"en_US","og_type":"article","og_title":"MYSQL tuning-primer - Linux Shtuff","og_description":"MySQL Performance Tuning Primer Script This script takes information from &#8220;SHOW STATUS LIKE&#8230;&#8221; and &#8220;SHOW VARIABLES LIKE&#8230;&#8221; to produce sane recommendations for tuning server variables. It is compatible with all versions of MySQL 3.23 and higher (including 5.1). Currently it handles recommendations for the following: # Slow Query Log # Max Connections # Worker Threads... Read More","og_url":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2010-02-11T07:50:54+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"MYSQL tuning-primer","datePublished":"2010-02-11T07:50:54+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/"},"wordCount":197,"commentCount":0,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/","url":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/","name":"MYSQL tuning-primer - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2010-02-11T07:50:54+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/mysql-tuning-primer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"MYSQL tuning-primer"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/2445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=2445"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/2445\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=2445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=2445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=2445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}