On the choice of fields by federated index

if there are three fields in the table: id, date, gender
if sometimes the query is (id, date, gender)
, sometimes the query is (id, gender)
is it possible to create a (id, date) joint index
because gender is not highly differentiated
does not need to be part of the index
where id=3 and date="2018-06-23 "and gender=0
where id=3 and gender=0
can you use this joint index
?

May.26,2022

Yes, you can all use this federated index

if the select field of the query has only (id, date, gender) , establishing a joint index of id, date, gender can avoid returning to the table, and the performance is better.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b384de-344cd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b384de-344cd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?