Get the App
SLTechnology News&Howtos  ›  Development  › 

The Operation Mode of query Optimizer in mysql

Shulou Source: shulou.com Published: 2022-06-03 13:10:06 11月14日 Update

This article mainly explains "the operation mode of query optimizer in mysql". The explanation in this article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "the operation mode of query optimizer in mysql".

1. MySQL uses a cost-based optimizer, which attempts to predict the cost of a query using a certain execution plan and selects the optimizer with the lowest cost.

2. The query optimizer needs to obtain the corresponding statistics from the storage engine to generate the execution plan of the query.

The storage engine provides the optimizer with corresponding statistical information, including: how many pages are there in a table or index, what is the cardinality of each index in each table, the length of data rows and indexes, the distribution of indexes, and so on. The optimizer selects the best implementation plan based on this information.

Example

Mysql > EXPLAIN SELECT * FROM tbl_name WHERE 0gamma Gmail * 1. Row * * id: 1select_type: SIMPLEtable: NULLtype: NULLpossible_keys: NULLkey: NULLkey_len: NULLref: NULLrows: NULLExtra: Impossible WHERE Thank you for reading. That's how the optimizer works in mysql. After the study of this article, I believe you have a deeper understanding of the operation of the query optimizer in mysql, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Queries methods indexes information costs learning content engines data storage statistics minimum middle cardinality examples that is ideas situations articles more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info Shulou Information MySQL Shulou Technology