Re: [PERFORM] Subquery in a JOIN not getting restricted?

2011-11-10 Thread Jay Levitt
Don't hold your breath waiting for that to change. To do what you're wishing for, we'd have to treat the GROUP BY subquery as if it were an inner indexscan, and push a join condition into it. That's not even possible today. Thanks! Knowing "that's not a thing" helps; we'll just have to rephras

Re: [PERFORM] Subquery in a JOIN not getting restricted?

2011-11-10 Thread Tom Lane
Jay Levitt writes: > If the query was more like > select questions.id > from questions > join ( >select sum(u.id) >from users as u >group by u.id > ) as s > on s.id = questions.user_id > where questions.id = 1; > would you no longer be surprised that it scanned all user rows? Don't

Re: [PERFORM] IMMUTABLE STABLE functions, daily updates

2011-11-10 Thread Craig Ringer
On Nov 10, 2011 9:26 PM, "Thom Brown" wrote: > > On 10 November 2011 13:05, Sorin Dudui wrote: > > Hi, > > > > > > > > I have some functions that select data from tables which are daily or > > monthly updated. My functions are marked as STABLE. I am wondering if they > > perform better if I mark

Re: [PERFORM] Subquery in a JOIN not getting restricted?

2011-11-10 Thread Jay Levitt
Kevin Grittner wrote: Merlin Moncure wrote: Well, this may not fit the OP's 'real' query Right, if I recall correctly, the OP said it was simplified down as far as it could be and still have the issue show. but the inner subquery is probably better written as a semi-join (WHERE EXISTS).

Re: [PERFORM] IMMUTABLE STABLE functions, daily updates

2011-11-10 Thread Thom Brown
On 10 November 2011 13:05, Sorin Dudui wrote: > Hi, > > > > I have some functions that select data from tables which are daily or > monthly updated.  My functions are marked as STABLE. I am wondering if they > perform better if I mark they as IMMUTABLE? No. IMMUTABLE is only appropriate when the

[PERFORM] IMMUTABLE STABLE functions, daily updates

2011-11-10 Thread Sorin Dudui
Hi, I have some functions that select data from tables which are daily or monthly updated. My functions are marked as STABLE. I am wondering if they perform better if I mark they as IMMUTABLE? Thank you, Sorin