Suppose I have two tables tab1, tab2. Full text indexes created on all varchar columns on these two tables. Then issue following SQL:
SELECT *
FROM tab1 a
JOIN tab2 b on a.ID = b.ID
WHERE CONTAINS(a.*, @keystring)
OR CONTAINS(b.*,@keystring)
It is pretty slowly(almost 30 seconds). But If I issue following SQL:
SELECT *
FROM tab1 a
JOIN tab2 b on a.ID = b.ID
WHERE CONTAINS(a.*, @keystring)
…or:
SELECT *
FROM tab1 a
JOIN tab2 b on a.ID = b.ID
WHERE CONTAINS(b.*,@keystring)
The performance is pretty good(less than second)
How to resolve this problem?
have you tried:
Or use UNION all if you don’t care if there are duplicates where the keystring is both tables.
Look at your execution plans to see the differnce but OR often makes as query run much more slowly.