Joint index
Index method: BTREE
1. When order by create_create is changed to order by id , the
data is incrementally inserted and ordered,
the primary key is generally the unique index of this table
2. The query conditions are not applicable or
if there is or, the SQL query will be divided into Two or more
Use Union to connect two SQL
3.limit 1 limit query format
4. Give up the use of indexes
condition | Example | illustrate |
set to NULL | number is null | |
!= or <> | number != 3 | Change to = connect with and in other cases |
or | a = 1 or b = 3 | Split into two SQL, use Union all to connect |
.in 和 not in | number in (2,3) | Use between for consecutive numbers, replace in with exist |
like | like "%have%" | |
Use index in where clause | Use the function DATE(CREATE_TIME) <= '' on the query condition | |
update | Update only the fields that need to be changed | Do not update the entire table |
Blog reference
database
SQL optimization summary 5. Date retrieval uses the percent sign after like, like "2017-10-29%"