Re: Function call with offset and limit - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Function call with offset and limit
Date
Msg-id 20051222101815.GC21783@svana.org
Whole thread Raw
In response to Re: Function call with offset and limit  (REYNAUD Jean-Samuel <reynaud@elma.fr>)
Responses Re: Function call with offset and limit  ("Jim C. Nasby" <jnasby@pervasive.com>)
List pgsql-hackers
On Thu, Dec 22, 2005 at 10:52:58AM +0100, REYNAUD Jean-Samuel wrote:
> Hi
>
> I've just tried it, and it works. So it's a good work-around.
>
> Though, is it a wanted feature to have a function being performed on
> each row before the offset ?

Well, saying offset 5000 pretty much means to calculate the first 5000
rows and throw away the result. To calculate that it needs to execute
the function each time. What happens if the function has side-effects
like in your case? What if you had a WHERE clause that depended on the
result of that function?

If the function has no side-effects, like say pow() then the backend
could skip but that should be transparent to the user. SQL allows you
specify the way you want it and PostgreSQL is simply executing what you
wrote down...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

pgsql-hackers by date:

Previous
From: REYNAUD Jean-Samuel
Date:
Subject: Re: Function call with offset and limit
Next
From: Simon Riggs
Date:
Subject: Re: Unsplitting btree index leaf pages