Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why the mysql optimizer chose the clustered index

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "Why the mysql optimizer chose the clustered index". Many people will encounter this dilemma in the operation of the actual case, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The following case is used to illustrate the trade-off of the optimizer when choosing an index.

View the table structure:

MySQL > show create table test2\ gateway * 1. Row * * Table: test2Create Table: CREATE TABLE `test2` (`id`bigint (16) NOT NULL AUTO_INCREMENT, `order_ seq` bigint (16) NOT NULL, `order_ type` int (11) DEFAULT NULL, `order_ types` int (11) DEFAULT NULL, PRIMARY KEY (`id`) KEY `idx_ id` (`id`), KEY `idx_id_ orderseq` (`id`, `order_ seq`) ENGINE=InnoDB AUTO_INCREMENT=15002212 DEFAULT CHARSET=utf8mb41 row in set (0.00 sec)

Enquiry 1:

MySQL > explain select id,order_seq from test2 where id > 10000 and id explain select * from test2 where id > 10000 and id

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report