Quantcast
Channel: Go4Expert
Viewing all articles
Browse latest Browse all 1997

How to Tune SQL Statement with OR conditions in a Subquery for SQL Server?

$
0
0
The following is an example that shows a SQL statement with an EXISTS subquery. The SQL counts the records from the EMPLOYEE table if the OR conditions are satisfied in the subquery of the DEPARTMENT table.

select countn(*) from employee a where
exists (select 'x' from department b
where a.emp_id=b.dpt_manager or a.emp_salary=b.dpt_avg_salary)​

Here the following is the query plan in the Tosska proprietary tree format, it takes 4 minutes and 29 seconds to...

How to Tune SQL Statement with OR conditions in a Subquery for SQL Server?

Viewing all articles
Browse latest Browse all 1997

Trending Articles