私は実行に長い時間がかかる次のSQLを持っていますが、速度を向上させるためにこれを書くためのより良い方法はありますか?
どんな助けでも非常に高く評価されます。
ありがとう
SELECT a.KeyField
FROM Details a,
Master b
WHERE a.ForeignKeyField = b.ForeignKeyField
AND a.KeyField IS NOT NULL
AND Date BETWEEN
TO_DATE ('01-01-2011', 'dd-mm-yyyy') AND TO_DATE ('31-12-2011', 'dd-mm-yyyy')
AND a.KeyField IN
(SELECT p.KeyField
FROM Details p,
Master q
WHERE q.ForeignKeyField = p.ForeignKeyField
AND p.KeyField IS NOT NULL
AND p.KeyField = a.KeyField
AND q.FKField2 = b.FKField2
GROUP BY p.KeyField,
q.Date HAVING COUNT (DISTINCT q.ForeignKeyField) > 1)
GROUP BY b.Id,
b.Name,
b.ForeignKeyField,
b.Date,
a.ForeignKeyField,
a.SomeOtherField,
a.KeyField,
b.EtcEtc