J'ai trois façons de construire ma requête:Quelle requête sera la plus rapide?
Le premier:
select obj from table1 where condition1 and obj in (
select obj from table2 where condition2 and obj in (
select obj from table3 where condition3 and obj in (
...
)))
Le second:
select obj from table1 where condition1
and obj in (select obj from table2 where condition2)
and obj in (select obj from table3 where condition3)
...
Le troisième:
select table1.obj from table1
inner join table2 on table2.obj = table1.obj and table2.condition='condition2'
inner join table3 on table3.obj = table2.obj and table3.condition='condition3'
...
where table1.condition='condition1'
Mes questions est si ces requêtes fournissent le même résultat et si ces requêtes sont également optimales.
Je suis assez sûr que les deux premières requêtes produisent la même sortie, mais la deuxième requête est plus rapide. Je ne suis pas sûr de la troisième requête.
AJOUTÉE
Il y a aussi une autre option:
select table1.obj from table1
inner join table2 on table2.obj = table1.obj
inner join table3 on table3.obj = table2.obj
...
where
table1.condition='condition1' and
table2.condition='condition2' and
table3.condition='condition3'
Avez-vous essayé l'analyse comparative des 3? – scunliffe