>Margaret,
>
>COUNT() in general is slower than EXISTS.
>
>IF EXISTS ( SELECT * from Traveler tr JOIN deleted d on tr.fk_product = d.pk)
> AND EXISTS ( SELECT * from Trans_sernum ts JOIN deleted d on ts.fk_product = d.pk)
> AND EXISTS ( SELECT * FROM inserted i JOIN DELETED d ON d.pk = i.pk
>
>
Hi Sergey,
Small correction - first two conditions should be OR, e.g.
if (exists ... or exists ... ) and exists
BTW, what do you think is better:
select FirstName, LastName, count(Symbol) from Table1 inner join table2 on ..
group by firstname, lastname
or
select FirstName, LastName, cntTotal from Table1 inner join (select ... from Table2 group by .. )
I got better performance results (slightly) on the second variation. But I only have few records.
BTW, at home I got the same 50% for each query. Is there a way to save execution plan in a text file (SQL Server 2000)?
I'm going now to try to populate these tables with millions of records in a loop and test the performance again.
After populating tables I got the subquery version as a winner. Do you think adding indexes on FirstName and LastName may help?
Thanks in advance.
If it's not broken, fix it until it is.
My Blog