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

High ratio of rows returned to index

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

Share

Shulou(Shulou.com)06/01 Report--

In MySQL, the number of rows returned by the query exceeds 20% of the total number of rows, and the execution plan will not take the index. Let's look at an example to query information with an id greater than 1.

Click (here) to collapse or open

Mysql > explain select * from test06 where id > 1

+-- +

| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+-- +

| | 1 | SIMPLE | test06 | ALL | idx_test03_id | NULL | NULL | NULL | 2009559 | Using where |

When the proportion of returned rows is high, the optimizer thinks that full table scanning saves time. Indexes are not used.

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