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) 

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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -