{"id":12,"date":"2009-12-29T16:56:33","date_gmt":"2009-12-29T13:56:33","guid":{"rendered":"http:\/\/meekconsulting.com\/?p=12"},"modified":"2009-12-29T16:57:37","modified_gmt":"2009-12-29T13:57:37","slug":"faster-mysqll-index-creation","status":"publish","type":"post","link":"https:\/\/meekconsulting.com\/?p=12","title":{"rendered":"Faster MYSQL Index creation"},"content":{"rendered":"<p>Creating indexes in mysql on large tables can take a long time.  Because it makes a temporary copy of the entire DB file first then creates the indexes.<\/p>\n<p>So be sure you have enough free space for the complete DB ( MYI and MYD for MYISAM databases ) plus space for the new version.<\/p>\n<p>If you need to create multiple indexes doing them all in one command saves the time of creating that copy of the DB each time ( many hours in some cases )<\/p>\n<p>Also increasing the Sort buffer sizes will greatly speed things up.<\/p>\n<p>Here is the SQL we used to reduce creation time from 4 days to 11 hours on a 400 Million record table (80Gig Size).<\/p>\n<blockquote><p>set myisam_sort_buffer_size=2000000000;<br \/>\nset sort_buffer_size=2000000000;<br \/>\nalter table schema.tablename<br \/>\nadd index index1 using BTREE(field1,field2),<br \/>\nadd index index2 using BTREE(field3,field4),<br \/>\nadd index index3 using BTREE(field5);<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Creating indexes in mysql on large tables can take a long time. Because it makes a temporary copy of the entire DB file first then creates the indexes. So be sure you have enough free space for the complete DB &hellip; <a href=\"https:\/\/meekconsulting.com\/?p=12\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[3],"_links":{"self":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/12"}],"collection":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12"}],"version-history":[{"count":3,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":15,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions\/15"}],"wp:attachment":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}