ref_table_id、ref_objid の 2 つの列を持つテーブルがあります。このテーブルは、他のテーブルのオブジェクトを参照するために使用されます。実際には 2 つ以上の列がありますが、他の列は重要ではありません。
次のクエリの実行には 1 秒かかります。
delete from ref_table_id
where (ref_table_id = 1 and
ref_objid not in (select objid from table1))
同様に、このクエリの実行には 1 秒かかります。
delete from ref_table_id
where (ref_table_id = 2 and
ref_objid not in (select objid from table2))
ただし、このクエリの実行には 3 分かかります。
delete from ref_table_id
where (ref_table_id = 1 and
ref_objid not in (select objid from table1))
or (ref_table_id = 2 and
ref_objid not in (select objid from table2))
最後のクエリに時間がかかるのはなぜですか? 基本的には、最初の 2 つの組み合わせです。誰でもこれを説明できますか?
オラクルを使用しています。
ありがとうございました