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

Optimization of COUNT (*) by InnoDB under MySQL 5.7

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

In MySQL 5.7COUNT (), the total number of tables can be quickly obtained by selecting a clustered index and making an internal handler function call.

The execution plan shows: Extra:Select tables optimized away

In previous versions, the COUNT () request would normally be: scan the normal index to get this total.

6. The execution plan shows: Extra:Using index

If the clustered index is large (or the table has a large amount of data) and is not fully loaded into the buffer pool, the query mode of MySQL 5.7may be slower instead of using the original way (MySQL 5.6)

Solution: force the general index, but you still need to add WHERE conditions, otherwise it will not work.

Select count () from stock force index (idx_stock) where id > 0

Extra:using where,using index

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