{"id":792,"date":"2008-04-15T17:11:13","date_gmt":"2008-04-15T22:11:13","guid":{"rendered":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified"},"modified":"2008-04-15T17:17:30","modified_gmt":"2008-04-15T22:17:30","slug":"explain-demystified","status":"publish","type":"post","link":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified","title":{"rendered":"EXPLAIN Demystified"},"content":{"rendered":"<p>Baron Schwartz gave a most interesting talk about EXPLAIN. You will definitely want to read his slides (filled with detail), when they make their way online. These notes are very sparse, just bits that I didn&#8217;t see in the slides, that Baron mentioned verbally. Plenty of good questions, and plenty of interaction.<\/p>\n<p>EXPLAIN only works for SELECT queries.<\/p>\n<p>How does MySQL execute queries? Optimisation happens even as the query is being executed. As the query is being optimised, some execution happens as well. Execution Plan is a data structure, not bytecode.<\/p>\n<p>When EXPLAIN&#8217;s output is generated, MySQL actually executes the query. It just set&#8217;s DESCRIBE on it, rather than executing it. Everything is a JOIN to MySQL (union, SELECT 1 [simplest base case join], etc&#8230;).<\/p>\n<p>key_len &#8211; to know if your table is indexed well.<\/p>\n<p>rows: estimated number of rows to read, but not the number of rows in the result set. In 5.1 and greater, it reflects LIMIT, but not before.<\/p>\n<p>Maatkit includes mk-visual, so you can have a visual explain. This is also, very machine readable.<\/p>\n<p><strong>Update:<\/strong> Artem has good <a href=\"http:\/\/beerpla.net\/2008\/04\/15\/mysql-conference-liveblogging-explain-demystified-tuesday-200p\/\">notes<\/a> too.<\/p>\n<p>Technorati Tags: <a class=\"performancingtags\" rel=\"tag\" href=\"http:\/\/technorati.com\/tag\/mysqluc08\">mysqluc08<\/a>, <a class=\"performancingtags\" rel=\"tag\" href=\"http:\/\/technorati.com\/tag\/mysqluc2008\">mysqluc2008<\/a>, <a class=\"performancingtags\" rel=\"tag\" href=\"http:\/\/technorati.com\/tag\/mysql\">mysql<\/a>, <a class=\"performancingtags\" rel=\"tag\" href=\"http:\/\/technorati.com\/tag\/baron%20schwartz\">baron schwartz<\/a>, <a class=\"performancingtags\" rel=\"tag\" href=\"http:\/\/technorati.com\/tag\/explain\">explain<\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20EXPLAIN%20Demystified&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2008%2F04%2F15%2Fexplain-demystified&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"2fce6befbc\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-792\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-792\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-792\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Baron Schwartz gave a most interesting talk about EXPLAIN. You will definitely want to read his slides (filled with detail), when they make their way online. These notes are very sparse, just bits that I didn&#8217;t see in the slides, that Baron mentioned verbally. Plenty of good questions, and plenty of interaction. EXPLAIN only works [&hellip;]<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20EXPLAIN%20Demystified&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2008%2F04%2F15%2Fexplain-demystified&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"2fce6befbc\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-792\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-792\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-792\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/15\/explain-demystified?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[23],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4vJD-cM","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2286,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/practical-mysql-indexing-guidelines-by-stephane-combaudon","url_meta":{"origin":792,"position":0},"title":"Practical MySQL Indexing guidelines by St\u00c3\u00a9phane Combaudon","date":"5\/2\/2012","format":false,"excerpt":"St\u00e9phane Combaudon of Dailymotion. Index: separate data structure to speed up SELECTs. Think of index in a book. In MySQL, key=index. Consider that indexes are trees. InnoDB's clustered index - data is stored with the Primary Key (PK) so PK lookups are fast. Secondary keys hold the PK values. Designing\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3202,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2016\/04\/08\/fosdem-2016-notes","url_meta":{"origin":792,"position":1},"title":"FOSDEM 2016 notes","date":"8\/4\/2016","format":false,"excerpt":"While being on the committee for the FOSDEM MySQL & friends devroom, I didn't speak at that devroom (instead I spoke at the distributions devroom). But when I had time to pop in, I did take some notes on sessions that were interesting to me, so here are the notes.\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":537,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/04\/26\/mysql-at-google","url_meta":{"origin":792,"position":2},"title":"MySQL at Google","date":"26\/4\/2007","format":false,"excerpt":"MySQL: The Real Grid Database, Mark Callaghan, Chip Turner A tremendous amount of work also done by Wei Li and Gene Pang. Google has a large MySQL deployment, and they enhance it as needed. MySQL@Google: too many queries, transactions, data, and rapid growth. Real workload with OLTP and reporting. Workload\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2298,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/managing-mysql-with-percona-toolkit-by-frederic-descamps","url_meta":{"origin":792,"position":3},"title":"Managing MySQL with Percona Toolkit by Fr\u00c3\u00a9d\u00c3\u00a9ric Descamps","date":"5\/2\/2012","format":false,"excerpt":"Fr\u00e9d\u00e9ric Descamps of Percona. Percona Toolkit is Maatkit & Aspersa combined. Opensource and the tools are very useful for a DBA. You need Perl, DBI, DBD::mysql, Term::ReadKey. Most tools are written in Perl, and whatever is in Bash is being re-written in Perl. There is also a tarball or RPM\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2256,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2012\/02\/05\/mariadb-5-3-query-optimizer-by-sergey-petrunia","url_meta":{"origin":792,"position":4},"title":"MariaDB 5.3 query optimizer by Sergey Petrunia","date":"5\/2\/2012","format":false,"excerpt":"Sergey Petrunia of the MariaDB project. What exactly is not working in MySQL? MySQL is poor at decision support\/analytics. With large datasets you need special disk access strategies. Complex queries like insufficient subquery support and big joins are common int he MySQL world. DBT-3 is used, scale=30, with a 75GB\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":806,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/02\/netbeans-61-with-glassfish-mysql-bundle","url_meta":{"origin":792,"position":5},"title":"NetBeans 6.1 with GlassFish, MySQL bundle","date":"2\/5\/2008","format":false,"excerpt":"I couldn't resist downloading NetBeans 6.1, with GlassFish and the MySQL bundle, the moment I found out it was released. Pulling it down while at the Star Alliance Gold lounge in Singapore was easy enough, and it only took me an hour (its a pretty big bundle - 164MB, as\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/792"}],"collection":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/comments?post=792"}],"version-history":[{"count":0,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/792\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/media?parent=792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/categories?post=792"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/tags?post=792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}