Re: Handle LIMIT/OFFSET before select clause (was: [HACKERS] Feature request: optimizer improvement)

2013-11-05 Thread Atri Sharma
On Tue, Nov 5, 2013 at 11:55 PM, Tom Lane wrote: > Joe Love writes: >> I'm wondering what type of index would work for this as it is a volatile >> function. Not knowing how PGs optimizer runs, I'm at a loss as to why this >> wouldn't be possible or worth doing. It seems to me that all functions i

Re: Handle LIMIT/OFFSET before select clause (was: [HACKERS] Feature request: optimizer improvement)

2013-11-05 Thread Tom Lane
Joe Love writes: > I'm wondering what type of index would work for this as it is a volatile > function. Not knowing how PGs optimizer runs, I'm at a loss as to why this > wouldn't be possible or worth doing. It seems to me that all functions in > the "select" part of the statement could be calcula

Re: Handle LIMIT/OFFSET before select clause (was: [HACKERS] Feature request: optimizer improvement)

2013-11-05 Thread Joe Love
I'm wondering what type of index would work for this as it is a volatile function. Not knowing how PGs optimizer runs, I'm at a loss as to why this wouldn't be possible or worth doing. It seems to me that all functions in the "select" part of the statement could be calculated at the end of the quer

Re: Handle LIMIT/OFFSET before select clause (was: [HACKERS] Feature request: optimizer improvement)

2013-11-02 Thread Tom Lane
Atri Sharma writes: > I understand the reasons for executing SELECT before the sort. But, > couldnt we get the planner to see the LIMIT part and push the sort > node above the select node for this specific case? [ Shrug... ] I don't see the point. If the OP actually cares about the speed of thi

Re: Handle LIMIT/OFFSET before select clause (was: [HACKERS] Feature request: optimizer improvement)

2013-11-02 Thread Atri Sharma
On Sat, Nov 2, 2013 at 2:00 AM, Tom Lane wrote: > Jim Nasby writes: >> On Oct 31, 2013, at 11:04 AM, Joe Love wrote: >>> In postgres 9.2 I have a function that is relatively expensive. When I >>> write a query such as: >>> >>> select expensive_function(o.id),o.* from offeirng o where valid='Y'

Re: [HACKERS] Feature request: Optimizer improvement

2013-11-01 Thread David Johnston
Jim Nasby-2 wrote > Should that really matter in this case? ISTM we should always handle LIMIT > before moving on to the SELECT clause…? SELECT generate_series(1,10) LIMIT 1 David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Feature-request-Optimizer-improvement

Re: [HACKERS] Feature request: Optimizer improvement

2013-11-01 Thread Atri Sharma
On Friday, November 1, 2013, Jim Nasby wrote: > On Oct 31, 2013, at 2:57 PM, Kevin Grittner > > > wrote: > > Joe Love 'j...@primoweb.com');>> wrote: > > In postgres 9.2 I have a function that is relatively expensive. > > > What did you specify in the COST clause on the CREATE FUNCTION > statemen

Re: Handle LIMIT/OFFSET before select clause (was: [HACKERS] Feature request: optimizer improvement)

2013-11-01 Thread Tom Lane
Jim Nasby writes: > On Oct 31, 2013, at 11:04 AM, Joe Love wrote: >> In postgres 9.2 I have a function that is relatively expensive. When I >> write a query such as: >> >> select expensive_function(o.id),o.* from offeirng o where valid='Y' order by >> name limit 1; > Does anyone know what th

Re: [HACKERS] Feature request: Optimizer improvement

2013-11-01 Thread Jim Nasby
On Oct 31, 2013, at 2:57 PM, Kevin Grittner wrote: > Joe Love wrote: > >> In postgres 9.2 I have a function that is relatively expensive. > > What did you specify in the COST clause on the CREATE FUNCTION > statement? Should that really matter in this case? ISTM we should always handle LIMIT

Handle LIMIT/OFFSET before select clause (was: [HACKERS] Feature request: optimizer improvement)

2013-11-01 Thread Jim Nasby
On Oct 31, 2013, at 11:04 AM, Joe Love wrote: > In postgres 9.2 I have a function that is relatively expensive. When I write > a query such as: > > select expensive_function(o.id),o.* from offeirng o where valid='Y' order by > name limit 1; > > the query runs slow and appears to be running th

[HACKERS] Feature request: optimizer improvement

2013-10-31 Thread Joe Love
In postgres 9.2 I have a function that is relatively expensive. When I write a query such as: select expensive_function(o.id),o.* from offeirng o where valid='Y' order by name limit 1; the query runs slow and appears to be running the function on each ID, which in this case should be totally unn

Re: [HACKERS] Feature request: Optimizer improvement

2013-10-31 Thread Kevin Grittner
Joe Love wrote: > In postgres 9.2 I have a function that is relatively expensive. What did you specify in the COST clause on the CREATE FUNCTION statement? -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hacke

[HACKERS] Feature request: Optimizer improvement

2013-10-31 Thread Joe Love
In postgres 9.2 I have a function that is relatively expensive. When I write a query such as: select expensive_function(o.id),o.* from offeirng o where valid='Y' order by name limit 1; the query runs slow and appears to be running the function on each ID, which in this case should be totally unn