{"id":3023,"date":"2014-09-11T03:35:57","date_gmt":"2014-09-11T03:35:57","guid":{"rendered":"http:\/\/www.deuzebranaweb.com.br\/?p=3023"},"modified":"2014-09-11T03:35:57","modified_gmt":"2014-09-11T03:35:57","slug":"mysql-optimization","status":"publish","type":"post","link":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/2014\/09\/11\/mysql-optimization\/","title":{"rendered":"MySQL optimization"},"content":{"rendered":"<h2>MySQL optimization<\/h2>\n<table style=\"height: 1491px;\" border=\"0\" width=\"899\" align=\"CENTER\">\n<tbody>\n<tr>\n<td align=\"CENTER\" valign=\"TOP\" width=\"20\">\n<table style=\"height: 535px;\" border=\"0\" width=\"10\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td><span style=\"font-size: small;\">products:<\/span><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/tgs\/\">TGS<\/a><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/tts\/\">TTS<\/a><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/tse\/\">TSE<\/a><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/tes\/\">TES<\/a><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/tps\/\">TPS<\/a><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/tcs\/\">TCS<\/a><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/tsela\/\">TSELA<\/a><\/td>\n<\/tr>\n<tr>\n<td>\u00a0\u00a0\u00a0<a href=\"http:\/\/www.t-scripts.com\/nitro\/\">Nitro<\/a><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: small;\">services:<\/span><br \/>\n<a href=\"http:\/\/www.t-scripts.com\/programming\/\">programming<\/a><br \/>\n<a href=\"http:\/\/www.t-scripts.com\/sysadmin\/\">system administration<\/a><br \/>\n<a href=\"http:\/\/www.t-scripts.com\/security\/\">security<\/a><br \/>\n<a href=\"http:\/\/www.t-scripts.com\/seo\/\">search engine optimization<\/a><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: small;\">tutorials:<\/span><br \/>\n<a href=\"http:\/\/www.t-scripts.com\/perl\/\">perl &amp; mysql<\/a><br \/>\n<a href=\"http:\/\/www.t-scripts.com\/php\/\">php &amp; mysql<\/a><br \/>\n<a href=\"http:\/\/www.t-scripts.com\/mysql\/\">mysql optimization<\/a><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/www.t-scripts.com\/contact.html\">Contact us<\/a><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/www.t-scripts.com\/\">T Scripts home<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<td valign=\"top\">\n<p align=\"Justify\"><span style=\"font-family: Arial;\"><b>MySQL optimization<\/b>. Here we will give some quick help on optimizing MySQL database performance.<\/span><\/p>\n<p align=\"Justify\"><span style=\"font-family: Arial;\"><b>Requirements<\/b>: MySQL.<\/span><\/p>\n<p align=\"Justify\"><span style=\"font-family: Arial;\">One of the factors with the biggest impact on database performance is not the MySQL settings, but your queries! Make sure you have optimized all your queries first, and have created the right indexes on your tables for MySQL to use.<\/span><\/p>\n<p align=\"Justify\"><span style=\"font-family: Arial;\">A useful MySQL command for this is EXPLAIN. If you use EXPLAIN SELECT * FROM table WHERE field=&#8221;something&#8221; , MySQL will tell you how many rows it needs to search, and what index it can use for this, among other things.<\/span><\/p>\n<p align=\"Justify\"><span style=\"font-family: Arial;\">After you have optimized your queries and created indexes, you can start tweaking your my.cnf MySQL configuration file. Keep in mind that if you optimize or change something you should be able to benchmark it to make sure it will actually increase the performance.<\/span><\/p>\n<p align=\"Justify\"><span style=\"font-family: Arial;\">Here is a sample my.cnf file (MySQL 4.1) for use on a dual processor server with 2GB of RAM memory:<\/span><\/p>\n<pre><span style=\"font-family: Arial;\"># The following options will be passed to all MySQL clients\n[client]\nsocket=\/tmp\/mysql.sock\n\n\n# The MySQL server\n[mysqld]\ntmpdir=\/tmp\nsocket=\/tmp\/mysql.sock\nskip-locking\nskip-networking\nskip-name-resolve\n\nserver-id=1\n\nmax_connections=500\nkey_buffer_size=384M\nmax_allowed_packet=16M\ntable_cache=256\nsort_buffer_size=2M\nread_buffer_size=2M\njoin_buffer_size=2M\n\n# if you are performing GROUP BY or ORDER BY queries on tables that\n# are much larger than your available memory, you should increase\n# the value of read_rnd_buffer_size to speed up the reading of rows\n# following sorting operations. \n# but: change the session variable only from within those clients \n# that need to run large queries\nread_rnd_buffer_size=2M\n\nmax_heap_table_size=256M\ntmp_table_size=256M\n\nmyisam_sort_buffer_size=64M\n\n# increase until threads_created doesnt grow anymore\nthread_cache=256\n\nquery_cache_type=1\nquery_cache_limit=1M\nquery_cache_size=32M\n\n# Try number of CPU's*2 for thread_concurrency\nthread_concurrency=4\n\n\n[mysqldump]\nquick\nmax_allowed_packet=16M\n\n[mysql]\nno-auto-rehash\n\n[isamchk]\nkey_buffer=128M\nsort_buffer_size=128M\nread_buffer=2M\nwrite_buffer=2M\n\n[myisamchk]\nkey_buffer=128M\nsort_buffer_size=128M\nread_buffer=2M\nwrite_buffer=2M\n\n[mysqlhotcopy]\ninteractive-timeout\n<\/span><\/pre>\n<p align=\"Justify\"><span style=\"font-family: Arial;\">You can use the SHOW STATUS MySQL command to monitor some of the variables (like Threads_created , Created_tmp_disk_tables , Created_tmp_tables and so on).<\/span><\/p>\n<p align=\"Justify\"><span style=\"font-family: Arial;\">If you would like more information, feel free to <a href=\"http:\/\/www.t-scripts.com\/contact.html\">contact us<\/a>.<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"nETbjHKwp2\"><p><a href=\"https:\/\/t-scripts.com\/mysql\/\">MySQL optimization<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;MySQL optimization&#8221; &#8212; T Scripts\" src=\"https:\/\/t-scripts.com\/mysql\/embed\/#?secret=y5c7o2uslj#?secret=nETbjHKwp2\" data-secret=\"nETbjHKwp2\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"ikcI1FHjoY\"><p><a href=\"https:\/\/t-scripts.com\/php\/\">PHP &amp; MySQL<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;PHP &amp; MySQL&#8221; &#8212; T Scripts\" src=\"https:\/\/t-scripts.com\/php\/embed\/#?secret=bX90rEUVtm#?secret=ikcI1FHjoY\" data-secret=\"ikcI1FHjoY\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL optimization products: \u00a0\u00a0\u00a0TGS \u00a0\u00a0\u00a0TTS \u00a0\u00a0\u00a0TSE \u00a0\u00a0\u00a0TES \u00a0\u00a0\u00a0TPS \u00a0\u00a0\u00a0TCS \u00a0\u00a0\u00a0TSELA \u00a0\u00a0\u00a0Nitro services: programming system administration security search engine optimization tutorials: perl &amp; mysql php &amp; mysql mysql optimization Contact us T Scripts home MySQL optimization. Here we will give some quick help on optimizing MySQL&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_angie_page":false,"page_builder":"","footnotes":""},"categories":[13],"tags":[],"class_list":["post-3023","post","type-post","status-publish","format-standard","hentry","category-msql"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts\/3023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=3023"}],"version-history":[{"count":0,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts\/3023\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=3023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=3023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=3023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}