zzz wrote:Not sure what do you mean by: "By ordering both ASC and DESC the indexes won't be used in mysql"
You have ordered like this:
ORDER BY
t2.altname_l,
t2.altname_f,
t1.name_l,
t1.name_f DESC
That is the same as below:
ORDER BY
t2.altname_l ASC,
t2.altname_f ASC,
t1.name_l ASC,
t1.name_f DESC
If you do not state in what order to order it will order ASC.
Normally when you order it uses the indexes to order the rows. If you for example "order by t1.fname ASC, t1.lname ASC, t1.state ASC, t1.city ASC, t1.street ASC" and you have all those columns in the index it will use the index to index. That means that it doesn't have to load the actual content of the table, compare that and index from it. But if you mix ASC and DESC "order by t1.fname ASC, t1.lname ASC, t1.state ASC, t1.city ASC, t1.street DESC" it can't use the indexes, it have to load the actual data instead.
About making sure that indexes are set properly I recommend you to search and read about indexes, the topic is to big and complex to explain quickly here.