本篇主要是上篇查询优化例子。
查询优化举例
连接5张表(persons, mobiles, mails, addresses, bank_accounts),获取个人全部信息。
SELECT * from PERSON, MOBILES, MAILS,ADRESSES, BANK_ACCOUNTSWHEREPERSON.PERSON_ID = MOBILES.PERSON_IDAND PERSON.PERSON_ID = MAILS.PERSON_IDAND PERSON.PERSON_ID = ADRESSES.PERSON_IDAND PERSON.PERSON_ID = BANK_ACCOUNTS.PERSON_ID
作为查询优化必须解决一下两个问题:
1. What kind of join should I use for each join?
有3种join,且还应考虑是否有索引或者有几个索引,什么类型索引,条件不同,选择的join都会不同。
2. What order should I choose to compute the