SlideShare une entreprise Scribd logo
1  sur  1
Télécharger pour lire hors ligne
Syntax: EXPLAIN <SELECT STATEMENT>
Explain Column Definitions
id A sequential ID
select_type See SELECT_TYPE
table The table or alias
type See TYPE
possible_keys The possible indexes that could be used
key The actually index used
key_len See KEY_LEN
ref The columns (or constants) used
rows Approximate # of rows returned
Extra See EXTRA
EXTRA
const row not found The table was empty
Distinct Stops after first matching row
Full scan on NULL key No index lookup on a subquery
Impossible HAVING HAVING is always false
Impossible WHERE WHERE is false for all rows
Impossible WHERE
noticed after reading
const tables
WHERE is false for all rows after const (and system)
tables have been read
No tables used No FROM
Not exists LEFT JOIN optimization. Stops after first row match
Range checked for each
record (index map: N)
No good index found. One might be available as query
is processed
Select tables
optimized away
Only aggregate functions that can be resolved using an
index
Using filesort Sorting was needed rather than using an index
Using temporary During execution a temporary table was required
Using index The query was satisfied using only an index
Using where A WHERE clause exists
Using index for group-
by
GROUP BY or DISTINCT query can be satisfied with
an index
Using sort_union(...),
Using union(...),
Using intersect(...)
index_merge join type
Using join buffer Join was performed using an internal buffer
KEY_LEN
tinyint 1 byte TIMESTAMP 4 bytes
smallint 2 bytes DATETIME 8 bytes
INT 4 bytes CHAR(n) n bytes
BIGINT 8 bytes VARCHAR(n) n bytes + 2 bytes
DATE 3 bytes NULL possible +1 byte
Warning! Multibyte characters make byte!=character. UTF8 is 3 bytes
SELECT_TYPE
SIMPLE Simple SELECT
PRIMARY First SELECT in a UNION or outer query in a
subquery
UNION Second or later SELECT in a UNION
DEPENDENT UNION Second or later SELECT in a UNION
dependent on outer query
UNION RESULT Result of a UNION
SUBQUERY First SELECT in a subquery
DEPENDENT
SUBQUERY
First SELECT in a subquery. It is dependent
on an outer variable
DERIVED Derived table. SELECT subquery in FROM
clause
UNCACHEABLE
SUBQUERY
Result of subquery must be re-evaluated for
each other query row
TYPE
system The table has only one value (a system table)
const Exactly one matching row using PRIMARY or UNIQUE
eq_ref One row is matched from this table for each combination of rows
from the previous tables.
ref All matching rows from this table for each combination of rows
from the previous tables.
fulltext FULLTEXT index is used
ref_or_null ref with an additional pass for NULL values
index_merge Index merge optimization used
unique_subquery Optimized subquery handling in queries of the form value IN
(SELECT …) using PRIMARY or UNIQUE keys
index_subquery Like unique_subquery but with non-unique indexes
range KEY is compared against =, <>, >, >=, <, <=, IS
NULL, <=>, BETWEEN, or IN()
index Same as ALL but only the index is scanned
ALL Full table Scan

Contenu connexe

Tendances

Apache Tez - A New Chapter in Hadoop Data Processing
Apache Tez - A New Chapter in Hadoop Data ProcessingApache Tez - A New Chapter in Hadoop Data Processing
Apache Tez - A New Chapter in Hadoop Data Processing
DataWorks Summit
 

Tendances (20)

Cost-based Query Optimization in Apache Phoenix using Apache Calcite
Cost-based Query Optimization in Apache Phoenix using Apache CalciteCost-based Query Optimization in Apache Phoenix using Apache Calcite
Cost-based Query Optimization in Apache Phoenix using Apache Calcite
 
Introduction to Spark Streaming
Introduction to Spark StreamingIntroduction to Spark Streaming
Introduction to Spark Streaming
 
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
Open Source Monitoring for Java with JMX and Graphite (GeeCON 2013)
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational Databases
 
Optimizing S3 Write-heavy Spark workloads
Optimizing S3 Write-heavy Spark workloadsOptimizing S3 Write-heavy Spark workloads
Optimizing S3 Write-heavy Spark workloads
 
Apache hive
Apache hiveApache hive
Apache hive
 
Apache Ambari: Past, Present, Future
Apache Ambari: Past, Present, FutureApache Ambari: Past, Present, Future
Apache Ambari: Past, Present, Future
 
Spark architecture
Spark architectureSpark architecture
Spark architecture
 
Performance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark MetricsPerformance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark Metrics
 
Apache Spark Core – Practical Optimization
Apache Spark Core – Practical OptimizationApache Spark Core – Practical Optimization
Apache Spark Core – Practical Optimization
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
Collaborative Filtering with Spark
Collaborative Filtering with SparkCollaborative Filtering with Spark
Collaborative Filtering with Spark
 
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiA Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
 
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
 
The Top Five Mistakes Made When Writing Streaming Applications with Mark Grov...
The Top Five Mistakes Made When Writing Streaming Applications with Mark Grov...The Top Five Mistakes Made When Writing Streaming Applications with Mark Grov...
The Top Five Mistakes Made When Writing Streaming Applications with Mark Grov...
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 
Understanding Query Plans and Spark UIs
Understanding Query Plans and Spark UIsUnderstanding Query Plans and Spark UIs
Understanding Query Plans and Spark UIs
 
8. column oriented databases
8. column oriented databases8. column oriented databases
8. column oriented databases
 
Performance Analysis of Apache Spark and Presto in Cloud Environments
Performance Analysis of Apache Spark and Presto in Cloud EnvironmentsPerformance Analysis of Apache Spark and Presto in Cloud Environments
Performance Analysis of Apache Spark and Presto in Cloud Environments
 
Apache Tez - A New Chapter in Hadoop Data Processing
Apache Tez - A New Chapter in Hadoop Data ProcessingApache Tez - A New Chapter in Hadoop Data Processing
Apache Tez - A New Chapter in Hadoop Data Processing
 

En vedette

MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
Manikanda kumar
 
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinarHow to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinar
oysteing
 

En vedette (20)

MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 
Optimizing MySQL Queries
Optimizing MySQL QueriesOptimizing MySQL Queries
Optimizing MySQL Queries
 
Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
MySQL EXPLAIN Explained-Norvald H. Ryeng
MySQL EXPLAIN Explained-Norvald H. RyengMySQL EXPLAIN Explained-Norvald H. Ryeng
MySQL EXPLAIN Explained-Norvald H. Ryeng
 
What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really Doing
 
How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016How to analyze and tune sql queries for better performance vts2016
How to analyze and tune sql queries for better performance vts2016
 
MySQL 8.0: GIS — Are you ready?
MySQL 8.0: GIS — Are you ready?MySQL 8.0: GIS — Are you ready?
MySQL 8.0: GIS — Are you ready?
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best Practices
 
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinarHow to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinar
 
SQL window functions for MySQL
SQL window functions for MySQLSQL window functions for MySQL
SQL window functions for MySQL
 
MySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table Expressions MySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table Expressions
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server Defaults
 
What you wanted to know about MySQL, but could not find using inernal instrum...
What you wanted to know about MySQL, but could not find using inernal instrum...What you wanted to know about MySQL, but could not find using inernal instrum...
What you wanted to know about MySQL, but could not find using inernal instrum...
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lag
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 
MySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table ExpressionsMySQL 8.0: Common Table Expressions
MySQL 8.0: Common Table Expressions
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Similaire à My sql explain cheat sheet

6.3 my sql queryoptimization_part2
6.3 my sql queryoptimization_part26.3 my sql queryoptimization_part2
6.3 my sql queryoptimization_part2
Trần Thanh
 

Similaire à My sql explain cheat sheet (20)

Troubleshooting MySQL Performance add-ons
Troubleshooting MySQL Performance add-onsTroubleshooting MySQL Performance add-ons
Troubleshooting MySQL Performance add-ons
 
6.3 my sql queryoptimization_part2
6.3 my sql queryoptimization_part26.3 my sql queryoptimization_part2
6.3 my sql queryoptimization_part2
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
Squirrel do more_with_less_code_light_cheatsheet
Squirrel do more_with_less_code_light_cheatsheetSquirrel do more_with_less_code_light_cheatsheet
Squirrel do more_with_less_code_light_cheatsheet
 
Squirrel do more_with_less_code_cheat_sheet_1
Squirrel do more_with_less_code_cheat_sheet_1Squirrel do more_with_less_code_cheat_sheet_1
Squirrel do more_with_less_code_cheat_sheet_1
 
Advanced Excel Courses Mumbai
Advanced Excel Courses MumbaiAdvanced Excel Courses Mumbai
Advanced Excel Courses Mumbai
 
Sql basics v2
Sql basics v2Sql basics v2
Sql basics v2
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
 
Assignment 4
Assignment 4Assignment 4
Assignment 4
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Training
 
SQL report
SQL reportSQL report
SQL report
 
Ms excel
Ms excelMs excel
Ms excel
 
MySQL index optimization techniques
MySQL index optimization techniquesMySQL index optimization techniques
MySQL index optimization techniques
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Join in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer JoinJoin in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer Join
 
Ora faq
Ora faqOra faq
Ora faq
 
Ora faq
Ora faqOra faq
Ora faq
 
Join sql
Join sqlJoin sql
Join sql
 

Plus de Achievers Tech

Plus de Achievers Tech (6)

Accessibility: A Journey to Accessible Rich Components
Accessibility: A Journey to Accessible Rich ComponentsAccessibility: A Journey to Accessible Rich Components
Accessibility: A Journey to Accessible Rich Components
 
Agile - The Xtreme Labs Way
Agile - The Xtreme Labs WayAgile - The Xtreme Labs Way
Agile - The Xtreme Labs Way
 
Your Web Application Is Most Likely Insecure
Your Web Application Is Most Likely InsecureYour Web Application Is Most Likely Insecure
Your Web Application Is Most Likely Insecure
 
PHP Framework Battle
PHP Framework BattlePHP Framework Battle
PHP Framework Battle
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
 

My sql explain cheat sheet

  • 1. Syntax: EXPLAIN <SELECT STATEMENT> Explain Column Definitions id A sequential ID select_type See SELECT_TYPE table The table or alias type See TYPE possible_keys The possible indexes that could be used key The actually index used key_len See KEY_LEN ref The columns (or constants) used rows Approximate # of rows returned Extra See EXTRA EXTRA const row not found The table was empty Distinct Stops after first matching row Full scan on NULL key No index lookup on a subquery Impossible HAVING HAVING is always false Impossible WHERE WHERE is false for all rows Impossible WHERE noticed after reading const tables WHERE is false for all rows after const (and system) tables have been read No tables used No FROM Not exists LEFT JOIN optimization. Stops after first row match Range checked for each record (index map: N) No good index found. One might be available as query is processed Select tables optimized away Only aggregate functions that can be resolved using an index Using filesort Sorting was needed rather than using an index Using temporary During execution a temporary table was required Using index The query was satisfied using only an index Using where A WHERE clause exists Using index for group- by GROUP BY or DISTINCT query can be satisfied with an index Using sort_union(...), Using union(...), Using intersect(...) index_merge join type Using join buffer Join was performed using an internal buffer KEY_LEN tinyint 1 byte TIMESTAMP 4 bytes smallint 2 bytes DATETIME 8 bytes INT 4 bytes CHAR(n) n bytes BIGINT 8 bytes VARCHAR(n) n bytes + 2 bytes DATE 3 bytes NULL possible +1 byte Warning! Multibyte characters make byte!=character. UTF8 is 3 bytes SELECT_TYPE SIMPLE Simple SELECT PRIMARY First SELECT in a UNION or outer query in a subquery UNION Second or later SELECT in a UNION DEPENDENT UNION Second or later SELECT in a UNION dependent on outer query UNION RESULT Result of a UNION SUBQUERY First SELECT in a subquery DEPENDENT SUBQUERY First SELECT in a subquery. It is dependent on an outer variable DERIVED Derived table. SELECT subquery in FROM clause UNCACHEABLE SUBQUERY Result of subquery must be re-evaluated for each other query row TYPE system The table has only one value (a system table) const Exactly one matching row using PRIMARY or UNIQUE eq_ref One row is matched from this table for each combination of rows from the previous tables. ref All matching rows from this table for each combination of rows from the previous tables. fulltext FULLTEXT index is used ref_or_null ref with an additional pass for NULL values index_merge Index merge optimization used unique_subquery Optimized subquery handling in queries of the form value IN (SELECT …) using PRIMARY or UNIQUE keys index_subquery Like unique_subquery but with non-unique indexes range KEY is compared against =, <>, >, >=, <, <=, IS NULL, <=>, BETWEEN, or IN() index Same as ALL but only the index is scanned ALL Full table Scan