パフォーマンスの低い「存在しないクエリ」があります。したがって、「左結合クエリ」の方がパフォーマンスが向上すると思いますが、そうではありません。これらのクエリを VBA で実行しています。
ここに私の「存在しないクエリ」があります
SELECT * FROM MyTable AS t1
WHERE t1.ID_person = 1960081947465
and t1.ID_company <> 68550
and t1.FullTime + 26.3 >= 37.33
and t1.Date <= 20130101
and t1.Code not in (31,28)
and t1.FullTime < 100
and not exists (
select * from MyTable t2 where
t1.ID_person = t2.ID_person
and t2.ID_company <> 68550
and t2.FullTime + 26.3 >= 37.33
and t2.Date <= 20130101
and t2.Code not in (31,28)
and t1.Date< t2.Date
)
そして、これは私が同じ結果を達成しようとしている方法ですが、「左結合クエリ」を使用しています
SELECT * FROM MyTable AS t1
LEFT JOIN
(
select * from MyTable t2 where
and t2.ID_company <> 68550
and t2.FullTime + 26.3 >= 37.33
and t2.Date <= 20130101
and t2.Code not in (31,28)
) subq
ON t1.ID_person = subq.ID_person and t1.Date < subq.Date
WHERE t1.ID_person = 1960081947465
and t1.ID_company <> 68550
and t1.FullTime + 26.3 >= 37.33
and t1.Date <= 20130101
and t1.Code not in (31,28)
and t1.FullTime < 100
and subq.ID_person IS NULL
「左結合クエリ」のパフォーマンスが低下するのはなぜですか? もっと速くなると思いました。同じクエリの 3 番目のバージョンがありますが、「not in」を使用しています。クエリは「存在しないクエリ」に非常に似ているため、ここに投稿する必要はないと思います。
より良い/より高速な「左結合クエリ」を提案できる人はいますか???