One SQL statement is: select * fromuserwheregender1orderbyiddesc; indexing method: 1: add an index for gender 2: add an index for id 3: Add a joint index for id and gender it turns out that 1 is correct, with the gender Index, the SQL index level reaches the const level. if the Union index is used, the index level is reached.
One SQL statement is: select * from user where gender = '1' order by id desc; indexing method: 1: add an index for gender 2: add an index for id 3: adding a joint index for id and gender proves that 1 is correct. Using a gender Index, the SQL index level reaches the const level. if the Union index is used, the index level is reached.
An SQL statement is:
Select * from user where gender = '1' order by id desc;
Indexing method:
1: add an index for gender
2: add an index for the id
3: Add a joint index for id and gender
Facts prove
1 is correct. With the gender Index, the SQL index level reaches the const level.
If the Union index is used, the index level is reached.
In fact, when the database has 100 million data records, it queries the first data records.
1: 0.07 s
2: 0.2 + s
Therefore, the indexing speed of method 1 is faster.
,