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

How to solve the problem of slow page turning after the increase of MySQL data

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

Share

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

This article shows you how to solve the problem of slow page turning after the increase of MySQL data. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The most common performance problem encountered by MySQL is that the page turning speed becomes slower after the gradual increase in the amount of data, and the more backward the page turning speed is, if you use the fastest way to solve it, here is the solution, simple and convenient.

1. The current situation of the problem

The existing MySQL data sheet event_data, with a data volume of 367000, is as follows:

Mysql > select count (1) from event_data; +-+ | count (1) | +-+ | 367961 | +-+ 1 row in set (0.05sec)

It takes 382 seconds to use SQL-Limit paging query, as shown below:

SELECT a.* FROM event_data a WHERE a.receive_time > = '2018-03-28 0000 WHERE a.receive_time 00AND a.receive_time SELECT a.pk_id-> FROM event_data a-> WHERE a.receive_time > =' 2018-03-28 0000RV 00lv 00L'- > AND a.receive_time ORDER BY a.receive_time DESC-> LIMIT 56280L15 +-- + | pk_id | +-+ | ce7d990f39a4411c88ebb3240497e6f3 | | bd47b1c380c946c39b3ec172a262823f | | c1820a5633714a5e9a0b0c2abb092579 | | d58456cbe16d4cc4a20645c1126fb9b7 | | a1d786640ea048a7bd10bd9f12868d6d | | f590aa4f26034dd9af2f4ba0d4f7430c | | af3e81eb43b84467bd3e2c7ad31d6aff | | 3ee331dce2064a788515986a0a97ac2b | | 46f462dc4209499f90dad2dc4076e4ca | | 8ebb7ff55bc443e4854e583f6dc37ff7 | | | 883fd68d93dc49eab5b35ebf9ab8f8ee | | 932c264d6dd140f3ac4f07f3410ce147 | | 19b6426cdd664fe2983166e0cca93c53 | | 3a0bfa4e000e4b69bba1a6bed6545973 | | 5640a162380346f19d57a61c1dc0dd42 | +-+ 15 rows in set (0.03 sec) |

It only takes 30 milliseconds for the query result to return. Although the SQL change is very small, only the query result has been changed from A. * to a.pk_id, but the speed increase is huge.

Reason analysis: both SQL where conditional statements use indexes. There is no problem here, but the query results are different. If only that index column (override index) is included in the statement using the index query, then the query will be very fast. This is the case here.

By using the overlay index, the query time can be reduced by minimizing the number of rows that the query statement needs to scan the table.

3. Problem solving

According to the above analysis, we use table joins to achieve SQL optimization, as follows:

Select a.* FROM (SELECT pk_id FROM event_data c WHERE c.receive_time > = '2018-03-28 00 AND c.receive_time

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