In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to optimize the query in MySQLlimit, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
How to query Optimization in MySQLlimit
Also take 10 pieces of data.
Select*fromyanxue8_visitlimit10000,10select*fromyanxue8_visitlimit0,10
It's not a quantitative level.
On the Internet, there are also many of the five optimization guidelines for limit, which are translated from the MySQL manual, which are correct but not practical. Today, I found an article about limit optimization, which is very good.
In this paper, instead of using limit directly, we first get the id of offset and then directly use limitsize to get the data. According to his data, it is obviously better than using limit directly. Here I use the data to test in two cases. (test environment win2033+p4 dual core (3GHZ) + 4G memory MySQLlimit query)
How to query Optimization in MySQLlimit
1. When offset is relatively small
Select*fromyanxue8_visitlimit10,10
Run multiple times and keep the time between 0.0004 and 0.0005
Select*Fromyanxue8_visitWherevid > = (SelectvidFromyanxue8_visitOrderByvidlimit10,1) limit10
Multiple runs, the time is kept between 0.0005 and 0.0006, mainly 0.0006
Conclusion: when the offset offset is small, it is better to use limit directly. This is obviously the reason for the subquery.
2. When offset is big
Select*fromyanxue8_visitlimit10000,10
Run many times and keep the time at about 0.0187
Select*Fromyanxue8_visitWherevid > = (SelectvidFromyanxue8_visitOrderByvidlimit10000,1) limit10
Run many times, the time is kept at about 0.0061, only the former 1 / 3. It can be expected that the larger the offset, the better the latter.
In the future, you should pay attention to correct your own limit statement and optimize the MySQL.
The above is how to optimize queries in MySQLlimit. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.