SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

MongoDB (Advanced)
MongoDB (Advanced)MongoDB (Advanced)
MongoDB (Advanced)
TO THE NEW | Technology
 
Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...
Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...
Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...
Simplilearn
 

Was ist angesagt? (6)

MongoDB (Advanced)
MongoDB (Advanced)MongoDB (Advanced)
MongoDB (Advanced)
 
Hadoop HDFS.ppt
Hadoop HDFS.pptHadoop HDFS.ppt
Hadoop HDFS.ppt
 
Introduction to Apache Hadoop Eco-System
Introduction to Apache Hadoop Eco-SystemIntroduction to Apache Hadoop Eco-System
Introduction to Apache Hadoop Eco-System
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDB
 
Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...
Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...
Hive Tutorial | Hive Architecture | Hive Tutorial For Beginners | Hive In Had...
 
The Big Data Analytics Ecosystem at LinkedIn
The Big Data Analytics Ecosystem at LinkedInThe Big Data Analytics Ecosystem at LinkedIn
The Big Data Analytics Ecosystem at LinkedIn
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von Achievers Tech

Mehr von 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