Home Database Mysql Tutorial MYSQL explain 执行计划_MySQL

MYSQL explain 执行计划_MySQL

Jun 01, 2016 pm 01:19 PM
most plan

MySQLexplain

bitsCN.com 使用方法,在select语句前加上explain就可以了:
如:explain select * from test1
EXPLAIN列的解释:
table:显示这一行的数据是关于哪张表的
type:这是重要的列,显示连接使用了何种类型。从最好到最差的连接类型为const、eq_reg、ref、range、indexhe和ALL
possible_keys:显示可能应用在这张表中的索引。如果为空,没有可能的索引。可以为相关的域从WHERE语句中选择一个合适的语句
key: 实际使用的索引。如果为NULL,则没有使用索引。很少的情况下,MYSQL会选择优化不足的索引。这种情况下,可以在SELECT语句中使用USE INDEX(indexname)来强制使用一个索引或者用IGNORE INDEX(indexname)来强制MYSQL忽略索引
key_len:使用的索引的长度。在不损失精确性的情况下,长度越短越好
ref:显示索引的哪一列被使用了,如果可能的话,是一个常数
rows:MYSQL认为必须检查的用来返回请求数据的行数
Extra:关于MYSQL如何解析查询的额外信息。将在表4.3中讨论,但这里可以看到的坏的例子是Using temporary和Using filesort,意思MYSQL根本不能使用索引,结果是检索会很慢
extra列返回的描述的意义
Distinct:一旦MYSQL找到了与行相联合匹配的行,就不再搜索了
Not exists: MYSQL优化了LEFT JOIN,一旦它找到了匹配LEFT JOIN标准的行,就不再搜索了
Range checked for each Record(index map:#):没有找到理想的索引,因此对于从前面表中来的每一个行组合,MYSQL检查使用哪个索引,并用它来从表中返回行。这是使用索引的最慢的连接之一
Using filesort: 看到这个的时候,查询就需要优化了。MYSQL需要进行额外的步骤来发现如何对返回的行排序。它根据连接类型以及存储排序键值和匹配条件的全部行的行指针来排序全部行
Using index: 列数据是从仅仅使用了索引中的信息而没有读取实际的行动的表返回的,这发生在对表的全部的请求列都是同一个索引的部分的时候
Using temporary 看到这个的时候,查询需要优化了。这里,MYSQL需要创建一个临时表来存储结果,这通常发生在对不同的列集进行ORDER BY上,而不是GROUP BY上
Where used 使用了WHERE从句来限制哪些行将与下一张表匹配或者是返回给用户。如果不想返回表中的全部行,并且连接类型ALL或index,这就会发生,或者是查询有问题不同连接类型的解释(按照效率高低的顺序排序)
system 表只有一行:system表。这是const连接类型的特殊情况
const:表中的一个记录的最大值能够匹配这个查询(索引可以是主键或惟一索引)。因为只有一行,这个值实际就是常数,因为MYSQL先读这个值然后把它当做常数来对待
eq_ref:在连接中,MYSQL在查询时,从前面的表中,对每一个记录的联合都从表中读取一个记录,它在查询使用了索引为主键或惟一键的全部时使用
ref:这个连接类型只有在查询使用了不是惟一或主键的键或者是这些类型的部分(比如,利用最左边前缀)时发生。对于之前的表的每一个行联合,全部记录都将从表中读出。这个类型严重依赖于根据索引匹配的记录多少―越少越好
range:这个连接类型使用索引返回一个范围中的行,比如使用>或index: 这个连接类型对前面的表中的每一个记录联合进行完全扫描(比ALL更好,因为索引一般小于表数据)
ALL:这个连接类型对于前面的每一个记录联合进行完全扫描,这一般比较糟糕,应该尽量避免bitsCN.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can't exit win11 preview program Can't exit win11 preview program Jun 29, 2023 pm 12:04 PM

Can't exit win11 preview program? When we use the win11 system, the win11 preview program will be launched on the computer for us to use. However, some friends do not want to use this preview program. I hope this preview program can be launched. If you don’t know how to exit, the editor below We have compiled a tutorial guide for exiting the Win11 preview experience program. If you are interested, let’s take a look below! Tutorial guide for exiting the Win11 Insider Program 1. First press the shortcut key "win+i" to enter Windows Settings and click "Update and Security". 2. Then click "Windows Insider Program" in the left taskbar, as shown in the figure. 3. At this point you can see the experience on the right

Huawei P70 directly starts the Pioneer Plan and is officially on sale Huawei P70 directly starts the Pioneer Plan and is officially on sale Apr 19, 2024 pm 01:58 PM

Zhongguancun News: On the morning of April 18, Huawei suddenly announced that the P70 series of mobile phones are officially on sale under the Pioneer Plan. Friends who want to buy should be prepared to take action. According to past practice, Huawei's flagship mobile phones are very popular and will always be out of stock. . This time the Huawei P70 series has been renamed Pura, which means pure. Previously, Huawei's Yu Chengdong said: Since 2012, Huawei's P series smartphones have been like loyal partners, accompanying hundreds of millions of users around the world to spend countless precious moments and jointly witness the beauty and excitement of life. He deeply felt that the trust and love given by every user who chooses Huawei's P series is tantamount to a powerful driving force, always inspiring Huawei to move forward firmly on the road of innovation. Pura means pure.

Please recommend a cost-effective 1155-pin CPU Please recommend a cost-effective 1155-pin CPU Jan 14, 2024 pm 01:30 PM

Please recommend which 1155-pin CPU is the best. The current 1155-pin CPU with the highest performance is Intel Corei7-3770K. It has 4 cores and 8 threads, a base frequency of 3.5GHz, and supports TurboBoost2.0 technology, which can reach up to 3.9GHz. In addition, it is equipped with 8MB of level 3 cache and is an excellent processor with the LGA1155 pin, the most powerful CPU Intel Core i73770K. The LGA1155 interface is the interface type used by second and third generation Core processors. The best performing one is Intel Core i73770K. The parameters of this processor are as follows: 1. Applicable type: desktop; 2. CPU series: Core i7; 3. CPU

New title: Russia promotes upgrading of microelectronics industry: formulating new plan New title: Russia promotes upgrading of microelectronics industry: formulating new plan Oct 12, 2023 pm 11:05 PM

According to news on October 12, Russia has made important progress in the field of microelectronics. The Russian Ministry of Industry and Trade recently proposed a new microelectronics development roadmap aimed at improving the country's semiconductor technology level. It is understood that Russian microelectronics companies are currently able to produce chip products with a 130-nanometer process, and their new goal is to achieve large-scale production of 65-nanometer chips in 2026, followed by plans to manufacture 28-nanometer chips domestically in 2027, and in The move to achieve mass production of 14nm chips by 2030 has been highly praised by local experts, who believe that these technological advances will help Russia produce affordable laptops based on open source technologies such as Linux and RISC-V. Last year, the Russian government

Mass production in 2025, Changan Automobile reveals latest solid-state battery plan Mass production in 2025, Changan Automobile reveals latest solid-state battery plan Dec 03, 2023 pm 08:34 PM

According to news on December 3, Changan Automobile recently revealed the latest progress of its solid-state battery plan in its latest investor relations activity record. Changan Automobile is currently actively developing new electrolyte materials for semi-solid batteries and solid-state batteries, as well as key processes. According to our understanding, the company plans to gradually promote the development of solid-state batteries based on vehicle demand, and plans to gradually mass-produce applications from 2025. According to the editor's understanding, Changan Automobile is committed to improving the weight and energy density of batteries in the research and development of solid-state batteries. It is expected to reach 350-500 Wh/kg, and the volume energy density is also expected to reach 750-1000 Wh/L. It is expected that this new type of battery will be fully popularized by 2030. In addition, Changan Automobile is also developing lithium-sulfur batteries.

What are the best Python resources? What are the best Python resources? Sep 16, 2023 pm 02:29 PM

Resources for any programming language include video lessons, notes, and e-books. Here I'll list the best resources for Python. Python official documentation Many websites provide Python resources, but the official documentation is the best. Let’s take a look at the resources they offer. Python Beginners Guide - https://wiki.python.org/moin/BeginnersGuide Python Developer Guide - https://devguide.python.org/Free Python Books − https://wiki.python.org/moin/PythonBooksPyth

Which graphics card interface works best? Which graphics card interface works best? Feb 22, 2024 am 10:51 AM

With the rapid development of computer technology, graphics cards, as one of the important components of computers, play a pivotal role in games, graphic design and other fields. The graphics card interface is the bridge connecting the graphics card and the motherboard, affecting the performance and effect of the graphics card. So, which graphics card interface works best? Currently, there are three common graphics card interfaces on the market: PCI, AGP, and PCIe. Among them, the PCI interface is an early standard interface and is relatively outdated. For some old computers or simple office needs

Which website is the best to download win10 Which website is the best to download win10 Jun 29, 2023 pm 07:33 PM

Which website is the best to download win10? Nowadays, many friends like to download and install or reinstall the system online. This requires an excellent download platform. So which website is good for downloading the win10 system? Many friends don’t know how to operate in detail. The editor has compiled the download websites for the win10 system below. Good introduction, if you are interested, follow the editor to read below! A good introduction to win10 system download website Answer: System 520 is the best. The systems here are safe and reliable, and the installation method is also very simple, suitable for all users. 1. The system here has several benefits. 2. First of all, ensure safety and reliability. All systems can be installed normally without errors. 3. Secondly, the installation operation is very simple, and the system is installed with one click.

See all articles