Home > database >  The optimization of [for] an SQL statement
The optimization of [for] an SQL statement

Time:09-30

SELECT *
The FROM the TAB c
WHERE c.s. tatus=1
The ORDER BY ASC c.i d
LIMIT 0, 20

The execution of 50 s +, retrieved 1 the qualified data, this table 5.7 g, 1896002 records

Have what good optimization scheme, so many duplicate data, + index?




CodePudding user response:

A clustered index is built on id will not be so slow, a non clustered index is built on the status again more slowly

CodePudding user response:

Meet the conditions of data than the big, considering the status + id composite index, or consider id + the status of composite index
If table amount of data is not very big, composite index can change to a single bond index (only the first column)

CodePudding user response:



Old hasten out activities!

CodePudding user response:

Mysql or can do level data, using the explain to view the execution plan, then try to use the index, partion plan to debug,
  • Related