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

What is the MySQL SQL optimization method?

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

Share

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

This article mainly explains "what is the MySQL SQL optimization method". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what the MySQL SQL optimization method is.

A sql was found in slowlog for more than 10 seconds.

# Time: 2017-03-02T18:41:50.201376+08:00

# User@Host: oms_ readonly[ oms _ readonly] @ [10.xx.xx.xx] Id: 54124620

# Query_time: 11.005894 Lock_time: 0.000223 Rows_sent: 20 Rows_examined: 1838114

SET timestamp=1488451310

Select * from customers where `type` = 1 AND `status`

< 7 AND `isarea` = 6 AND `into_time`>

= '2016-12-01'AND `into_ time` explain select * from customers where `type` = 1 AND `status`

< 7 AND `isarea` = 6 AND `into_time`>

= '2016-12-01'AND `into_ time` select count (*) from customers where `type` = 1

+-+

| | count (*) |

+-+

| | 2373175 |

+-+

1 row in set (1.53 sec)

Mysql > select count (*) from customers where `status`

< 7; ->

+-+

| | count (*) |

+-+

| | 2494232 |

+-+

1 row in set (3.16 sec)

Mysql > select count (*) from customers where `isarea` = 6

+-+

| | count (*) |

+-+

| | 135347 |

+-+

1 row in set (0.15 sec)

Mysql > select count (*) from customers where `into_ time` > = '2016-12-01'AND `into_ time` explain select * from customers use index (isarea) where `type` = 1 AND `status`

< 7 AND `isarea` = 6 AND `into_time`>

= '2016-12-01'AND `into_ 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