Re: [HACKERS] LIMIT 1 == EXISTS optimization?

2009-10-02 Thread Tom Lane
Richard Rowell writes: > I'm no backend guru, so I was hoping someone could explain what the original > query-plan was doing. If all you need to know is if a row exists, why loop > over all 3M rows? It seems very simplistic to assume the a LIMIT 1 clause > on the end of all EXISTS subqueries wou

[HACKERS] LIMIT 1 == EXISTS optimization?

2009-10-02 Thread Richard Rowell
I was just troubleshooting a slow query SELECT * FROM da_answer a WHERE a.provider_id IN ( SELECT visibility_bypass_providers( 0, 0 ) ) OR -- ownership ( EXISTS ( -- Visibility grant SELECT v.client_answer_id FROM sp_client_answervisibility v JOIN sp_sharing_grou