<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Index on Myanglog</title><link>https://myangw.github.io/en/tags/index/</link><description>Recent content in Index on Myanglog</description><generator>Hugo -- 0.154.5</generator><language>en</language><lastBuildDate>Wed, 14 Jan 2026 23:15:45 +0900</lastBuildDate><atom:link href="https://myangw.github.io/en/tags/index/index.xml" rel="self" type="application/rss+xml"/><item><title>Real MySQL Chapter 6: Execution Plan Analysis Summary</title><link>https://myangw.github.io/en/posts/real-mysql-chapter-6-execution-plan-summary/</link><pubDate>Sun, 12 Sep 2021 00:00:00 +0900</pubDate><guid>https://myangw.github.io/en/posts/real-mysql-chapter-6-execution-plan-summary/</guid><description>&lt;p&gt;This exposition examines execution plans and index utilization across diverse scenarios in comprehensive detail.&lt;/p&gt;
&lt;h2 id="61-overview"&gt;6.1. Overview&lt;/h2&gt;
&lt;h3 id="execution-plan-definition"&gt;Execution Plan Definition&lt;/h3&gt;
&lt;p&gt;The optimizer formulates optimal execution strategies by consulting statistical information regarding data distribution across tables to devise optimal execution plans for query execution.&lt;/p&gt;
&lt;h3 id="query-execution-phases"&gt;Query Execution Phases&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Parse SQL statements into MySQL server-comprehensible components (SQL parsing)&lt;/li&gt;
&lt;li&gt;Examine parse tree to determine table reading sequence and index selection (optimization and execution plan formulation by optimizer)&lt;/li&gt;
&lt;li&gt;Retrieve data from storage engine according to selected sequence and indices&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="optimizer-categories"&gt;Optimizer Categories&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Most RDBMS systems, including MySQL, employ cost-based optimizers
&lt;ul&gt;
&lt;li&gt;Generate multiple feasible approaches for query processing, calculating costs for each execution plan utilizing cost information for unit operations and predicted statistical data for target tables&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Rarely employed rule-based optimization exists (establishes execution plans according to optimizer&amp;rsquo;s built-in priorities. Excludes statistical information such as record counts and column value distributions)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="statistical-information"&gt;Statistical Information&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Approximate record counts, unique value quantities in indices, et cetera&lt;/li&gt;
&lt;li&gt;Statistical information proves significantly inaccurate for small record counts. Occasionally necessitates forced renewal via analyze command
&lt;ul&gt;
&lt;li&gt;analyze command: Updates index key value distribution (selectivity)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Statistical information collection reads only 8 randomly selected index pages or quantity specified by innodb_stats_sample_pages parameter&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="62-execution-plan-analysis"&gt;6.2. Execution Plan Analysis&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Update, insert, delete statements lack execution plan verification methods. Create select statements with identical where clauses for verification&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="execution-plan-column-descriptions"&gt;Execution Plan Column Descriptions&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;id column&lt;/strong&gt;: Each select statement receives distinct id&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;select_type column&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;SIMPLE: Simple select without subqueries, et cetera&lt;/li&gt;
&lt;li&gt;PRIMARY: Outermost query in statements containing unions or subqueries&lt;/li&gt;
&lt;li&gt;UNION, DEPENDENT UNION, UNION RESULT&lt;/li&gt;
&lt;li&gt;SUBQUERY: Subqueries used outside from clause&lt;/li&gt;
&lt;li&gt;DEPENDENT SUBQUERY: Subqueries utilizing columns defined in outer select. Outer query executes first → subquery execution. Performance degradation&lt;/li&gt;
&lt;li&gt;DERIVED: Subqueries used in from clause&lt;/li&gt;
&lt;li&gt;UNCACHEABLE SUBQUERY, UNCACHEABLE UNION&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;table column&lt;/strong&gt;: Execution plans display per table rather than per unit select query
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;derived&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;union&amp;gt;&lt;/code&gt; within angle brackets indicate temporary tables&lt;/li&gt;
&lt;li&gt;Identical ids: Upper lines constitute driving tables. Driving tables are read first for driven table joining&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;type column&lt;/strong&gt;: Indicates record reading methodology for each table
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;const&lt;/strong&gt;: Unique index scan. Query processing returning precisely one record utilizing PK or unique key columns in where clause&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;eq_ref&lt;/strong&gt;: For join queries. First-read table column values equal-compared with next table&amp;rsquo;s PK or unique key&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ref&lt;/strong&gt;: Equal condition searching regardless of joins or constraints&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;range&lt;/strong&gt;: Index range scan! Index searched with ranges rather than single values&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;index_merge&lt;/strong&gt;: Multiple index utilization&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;index&lt;/strong&gt;: Index full scan (reads entire index)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ALL&lt;/strong&gt;: Full table scan - most inefficient&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;key column&lt;/strong&gt;: Final selected index displayed&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;rows column&lt;/strong&gt;: Shows approximate record quantities in target tables&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;extra column&lt;/strong&gt;: Performance-related statement displays&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="63-mysqls-principal-processing-methodologies"&gt;6.3. MySQL&amp;rsquo;s Principal Processing Methodologies&lt;/h2&gt;
&lt;h3 id="631-full-table-scan"&gt;6.3.1. Full Table Scan&lt;/h3&gt;
&lt;p&gt;Conditions include: extremely small table record counts, absence of index-utilizable conditions in where/on clauses, excessive matching records for range scans&lt;/p&gt;</description></item></channel></rss>