The MySQL EXPLAIN statement can obtain information about how MySQL executes the SELECT statement. The following describes how to use this statement for your reference.
EXPLAIN tbl_nameOr: EXPLAIN [EXTENDED] SELECT select_options
The MySQL EXPLAIN statement can be used as a synonym for DESCRIBE, or obtain information ab
In the daily work, we will sometimes slow query to record some long-running SQL statements, to find out these SQL statements does not mean that it is done, we often use the explain command to view the execution plan of these SQL statements, to see whether the SQL statement is used index, There is no full table scan, which can be viewed through the explain command. So we have an in-depth look at the cost-bas
Explain shows how MySQL uses indexes to process SELECT statements and join tables. Can help select better indexes and write more optimized query statements.Parse an SQL statement first to see what appearsEXPLAINSELECTS.Uid,S.Username,S.Name,F.Email,F.Mobile,F.Phone,F.PostalCode,F.AddressFromUchome_spaceAsS,Uchome_spacefieldAsFWHERE1NBSP; ANDsgroupid=0 and suid=f.uid 1. IdSelect identifier. This is the Select query serial number. This is
EXPLAIN for query optimization different SQL statement writing methods often lead to great performance differences. How can we know the SQL query execution overhead? MySQL provides the EXPLAIN keyword for us. When you add the EXPLAIN keyword before your select statement, MySQL will EXPLAIN how it processes the SELECT q
Explain plan is a good tool for analyzing SQL statements. It can even analyze statements without executing SQL statements. through analysis, we can know how Oracle connects to the table, how to scan the table (index scan or full table scan), and the index name used.
You need to interpret the analysis results in the order from inside to outside. the results of the explain plan Analysis are arranged in indent
Mysql EXPLAIN display usingfilesort introduction MySQLexplain
The syntax format of bitsCN.com is as follows:
EXPLAIN tbl_name
Or:
Explain select select_options
The EXPLAIN statement can be used as a synonym for DESCRIBE, or used to obtain information about the SELECT statement to be executed by MySQL.
The
The explain command is the first recommended command for solving database performance. Most performance problems can be solved simply by using this command. The explain command can be used to viewSQLThe statement execution result can help you select a better index and query statement, and write a better optimization statement.
Explain Syntax:
Different SQL statement writing methods often bring about great performance differences. How can we know the overhead of SQL query execution? MySQL provides the explain keyword for us. When you add the explain keyword before your select statement, MySQL will explain how it processes the SELECT query and provide the order of how the table is joined and joined, the
This article turns from a predecessor's article, feels writes very well, then turns over. This is the old man's original address: Http://www.111cn.net/database/mysql/81698.htmwhen we were optimizing SQL, we wanted to look at the efficiency of the SQL we wrote, and MySQL provided us with a command explain that could show the SQL efficiency we wrote. A common understanding error: MySQL does not execute SQL statements when executing
specifying "Unique:true" in the Ensureindex command. For example, insert 2 records into the table T4:
Db.t4.ensureIndex ({firstname:1, lastname:1}, {unique:true});
5. Forcing the use of indexes
The hint command can force an index to be used.
Db.t5.find ({age:{$lt:}). Hint ({name:1, age:1}). Explain ()
6. Delete Index
Delete all indexes in the T3 table
db.t3.dropIndexes ()
//delete firstname index in T4 table
db.t4.d
})
We can also create a composite unique index, which guarantees that the composite key value is unique. Such as:
Db.user.ensureIndex ({"userid": 1, "Age": 1},{"unique": true})
some parameters of the index
If you are creating an index on a document that already has data, you can execute the following command so that MongoDB creates the index in the background so that it does not block other operations when it is created. However, creating an index in a blocking way can make the entir
The explain tool can confirm that the execution plan is good and that the query has gone through a reasonable index. The execution plan of the query may change as the data changes. Calling method: Explain + [SQL statement].In addition, explain is limited:1. The impact of triggers, stored procedures, and custom functions on queries is not explained;2. Regardless o
First, explain functionThe explain function can provide a large number of query-related information, and if it is a slow query, it is the most important diagnostic tool. For example:Query on fields that have an index:>db.post.find ({"loc.city": "NY"}). Explain () { "cursor" : "Btreecursorloc.city_1", "Ismultikey" :false, "n" :0, "Nscannedobjects" :0, "nscanne
Explanation of the EXPLAIN command in MySQL
Explain shows how mysql uses indexes to process select statements and connect tables. It can help you select better indexes and write more optimized query statements.You can add the explain statement before the select statement:
For example:
Copy codeThe Code is as follows:Explain select surname, first_name form a, B wh
Explain shows how MySQL uses indexes to process SELECT statements and join tables. Can help select better indexes and write more optimized query statements. Using the method, add explain to the SELECT statement.I. Explanation of the Explain column1, id:select identifier. This is the Select query serial number. This is not important, the query sequence is the SQL
Mysql explain usage (Optimize Query), mysqlexplain
ExplainIt shows how mysql uses indexes to process select statements and connect tables. Can HelpSelect a better IndexAndWrite more optimized query statements.
1. Create a database
The created SQL statement is as follows:
/* Navicat MySQL Data Transfer Source Server : localhost-newpassword Source Server Version : 50550 Source Host : localhost Source Database : testExplain Targ
Description of the returned value for performance test of explain SQL statements bitsCN.com
Description of the return value for performance test of explain SQL statements
The returned values of the explain SQL statement performance test are as follows:
Mysql> explain select * from table;
+ ---- + ------------- + ----
Here we will introduce the EXPLAIN command in MySQL, and hope to help you explain how mysql uses indexes to process select statements and connect tables. It can help you select better indexes and write more optimized query statements.
You can add the explain statement before the select statement:
For example:
The code is as follows:
I have encountered some database problems during performance tests recently. I usually use slow query logs to find SQL statements with poor execution performance. However, I cannot find these SQL statements only,
I have encountered some database problems during performance tests recently. I usually use slow query logs to find SQL statements with poor execution performance. However, I cannot find these SQL statements only,
I have encountered some database problems during performance tests re
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.