3
IF EXISTSでクエリをラップすると非常に遅くなる
私は以下のクエリを持っています: select databasename from somedb.dbo.bigtable l where databasename ='someval' and source <>'kt' and not exists(select 1 from dbo.smalltable c where c.source=l.source) 上記のクエリは3秒で完了します。 上記のクエリが値を返す場合、ストアドプロシージャを終了する必要があるため、次のように書き直しました。 If Exists( select databasename from somedb.dbo.bigtable l where databasename ='someval' and source <>'kt' and not exists(select 1 from dbo.smalltable c where c.source=l.source) ) Begin Raiserror('Source missing',16,1) Return …