SQL Select Count in Where Clause Performance issue -
i have following sql query performs horribly due select count(1) statement in clause. can suggest way speed up? idea want rows returned there 1 invoice found.
select people.name, people.address people ((select count(1) invoices invoices.pid = people.id)=1)
- count(1) superstition
- what have count per row of people = cursor/loop action
so, try join this
select people.name, people.address people join invoices on invoices.pid = people.id group people.name, people.address having count(*) = 1 i'd hope have indexes, @ least on invoices.pid , people.pid, name, address
Comments
Post a Comment