wooody1245
Programmer
I have a store procedure to pull data from two different tables. This is a simplified version of the stored procedure:
This query takes about 1:30 to run. If I remove the or and have either table1 or table2, the indexes are used and the query takes about 5 seconds.
Why would OR affect the execution time?
Code:
select t1.fname, t1.lname, address from table1 t1
inner join table2 t2 on t1.member_id = t2.member_id
where (table1.fname like @fname or table2.fname like @fname)
and (table1.lname like @lname or table2.lname like @lname)
Why would OR affect the execution time?