About related optimization in the project--Paging query slow problem troubleshooting steps

The paging list query of 10 pieces of data in the project takes about 6 seconds. The original SQL only queries the table data of 3,000,014 rows, as shown in the figure:

Because it is a mysql database, mysql may view and analyze the execution of sql statements through explain and desc, as shown in the figure:

It can be seen that there is an index created. If there is a problem with the index creation, you can query the table by show index from tableName

Create an index, it is strange that the index query is still so slow, does the index not work or is not available after the index is created, so I tried to back up this table

 

-- create backup table
create table t_gateway_info_back select * from t_gateway_info;

 This just creates the table structure and data. Similarly, the time-consuming execution of the query on this table does not change. It can be seen from this that the index we created does not work. Why? Check the table structure field and define it as varchar(64 ) type, go back and look at the sql and find that there is a problem with the parameter type of the query condition (have you found the problem here?), modify the sql to execute the query, as shown in the figure:

 

 

At this point, the problem should be understood. You can see that mysql does one thing for us "implicit conversion".
 
 
 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326610047&siteId=291194637