[PERFORM] is it possible to for the planner to optimize this form?

2004-06-07 Thread Merlin Moncure
Right now, I am having trouble getting the planner to optimize queries in the form of select t.key, t.field from t a where ( select count(*) from t b where b.field a.field ) = k The subplan (either index or seq. scan) executes once for each row in t, which of

Re: [PERFORM] is it possible to for the planner to optimize this form?

2004-06-07 Thread Josh Berkus
Merlin, select t.key, t.field from t a where ( select count(*) from t b where b.field a.field ) = k The subplan (either index or seq. scan) executes once for each row in t, which of course takes forever. This query is a way of achieving LIMIT type results

Re: [PERFORM] is it possible to for the planner to optimize this

2004-06-07 Thread Duane Lee - EGOVX
Title: RE: [PERFORM] is it possible to for the planner to optimize this form? I didn't really look that closely at the problem but have you thought of trying: select t.key, t.field from t a , (select count(*) as cntb from t b where b.field a.field) as dmytbl where cntb = k This is