Ich habe zwei Abfragen, die das gleiche Ergebnis ausgeben. Ich würde gerne wissen, ob es einen Unterschied in der Leistung der beiden gibt und welche besser zu verwenden ist. Bitte erläutern Sie, warum einer besser ist als der andere oder ob sie gleich sind.SQL Performance zwischen zwei Abfragen
Query2 ist 12 ms schneller als Query1, aber das könnte das Ergebnis einer zufälligen Serververzögerung sein. Zum Beispiel, wenn ich es erneut laufe, bekomme ich unterschiedliche Zeiten für jeden.
Abfrage 1: Zeit 66 ms
select
*
from
table1,
table2,
table3,
table4,
table5,
table6,
table7
where
table1.type1 = 402 and
table1.pid = table2.pid and
table1.aid = table3.aid and
table1.tid = table4.tid and
table4.type2 = table5.code and
table1.status = table6.code2 and
table7.eaid = table1.caid
Abfrage 2: Zeit - 54ms
select
*
from
table1
join table2 on table2.pid= table1.pid
join table3 on table1.aid = table3.aid
join table4 on table1.tid = table4.tid
join table5 on table4.type2= table5.code
join table6 on table1.status= table6.code2
join table7 on table7.eaid= table1.caid
where
table1.type1 = 402
Bitte fügen Sie die tatsächlichen Abfragepläne zu Ihrer Frage hinzu. –
Hier http://programmers.stackexchange.com/questions/78225/using-join-keyword-or-not – jayvee
Sie sehen zwar aus wie identische Abfragen, aber Abfrage 2 ist ANSI-kompatibel. –