Hi guys,
Right now I know this:
SELECT *
FROM TABLE
WHERE CAMPO1 = 'Something' AND CAMPO2 = 'Other'
If I used this Query without index it will do a Full Scan in my table to find my two conditions... But If I add an Index with this two fields it will be an index scan (faster) and I see the difference on the execution plan.
My question is? what about to do? when I have two Join Tables, for example:
SELECT *
FROM TABLE1 T1 INNER JOIN TABLE2 T2
ON T1.CAMPOT1 = T2.CAMPOT2
WHERE T1.CAMPO1 = 'Something' AND T2.CAMPO2 = 'Other'
As you can see my conditions are two but for different tables, in this case what I have to do in order to improve my index here? One index for Table1 with Campo1 and one index for table2 with Campo2 only? Or do I have to consider what I have on my "ON" expression?
Thanks for any suggestions!
MR
Right now I know this:
SELECT *
FROM TABLE
WHERE CAMPO1 = 'Something' AND CAMPO2 = 'Other'
If I used this Query without index it will do a Full Scan in my table to find my two conditions... But If I add an Index with this two fields it will be an index scan (faster) and I see the difference on the execution plan.
My question is? what about to do? when I have two Join Tables, for example:
SELECT *
FROM TABLE1 T1 INNER JOIN TABLE2 T2
ON T1.CAMPOT1 = T2.CAMPOT2
WHERE T1.CAMPO1 = 'Something' AND T2.CAMPO2 = 'Other'
As you can see my conditions are two but for different tables, in this case what I have to do in order to improve my index here? One index for Table1 with Campo1 and one index for table2 with Campo2 only? Or do I have to consider what I have on my "ON" expression?
Thanks for any suggestions!
MR