Re: [GENERAL] Query runs in 335ms; function in 100,239ms : date problem?

2011-09-06 Thread Tom Lane
"Tomas Vondra" writes: > On 6 Září 2011, 0:27, Rory Campbell-Lange wrote: >> The prepared query runs in almost exactly the same time as the function, >> but thanks for the suggestion. A very useful aspect of it is that I was >> able to get the EXPLAIN output which I guess gives a fairly good pi

Re: [GENERAL] Query runs in 335ms; function in 100,239ms : date problem?

2011-09-06 Thread Torsten Zühlsdorff
Rory Campbell-Lange schrieb: Try to run it as a prepared query - I guess you'll get about the same run time as with the function (i.e. over 100 seconds). The prepared query runs in almost exactly the same time as the function, but thanks for the suggestion. A very useful aspect of it is that I

Re: [GENERAL] Query runs in 335ms; function in 100,239ms : date problem?

2011-09-05 Thread Tomas Vondra
On 6 Září 2011, 0:27, Rory Campbell-Lange wrote: > On 05/09/11, Tomas Vondra (t...@fuzzy.cz) wrote: >> Do I understand correctly that you compare a query with literal >> parameters >> with a parametrized query wrapped in a plpgsql function? > > Yes! Certainly I need to make the function perform mor

Re: [GENERAL] Query runs in 335ms; function in 100,239ms : date problem?

2011-09-05 Thread Rory Campbell-Lange
On 05/09/11, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > On 05/09/11, Tomas Vondra (t...@fuzzy.cz) wrote: > > On 5 Zá??í 2011, 23:07, Rory Campbell-Lange wrote: > ... > > > The query itself runs in about a 1/3rd of a second. When running the > > > query as a 'RETURN QUERY' function on Po

Re: [GENERAL] Query runs in 335ms; function in 100,239ms : date problem?

2011-09-05 Thread Rory Campbell-Lange
On 05/09/11, Tomas Vondra (t...@fuzzy.cz) wrote: > On 5 Zá??í 2011, 23:07, Rory Campbell-Lange wrote: ... > > The query itself runs in about a 1/3rd of a second. When running the > > query as a 'RETURN QUERY' function on Postgres 8.4, the function runs in > > over 100 seconds, about 300 times slowe

Re: [GENERAL] Query runs in 335ms; function in 100,239ms : date problem?

2011-09-05 Thread Tomas Vondra
On 5 Září 2011, 23:07, Rory Campbell-Lange wrote: > I have a function wrapping a (fairly complex) query. > > The query itself runs in about a 1/3rd of a second. When running the > query as a 'RETURN QUERY' function on Postgres 8.4, the function runs in > over 100 seconds, about 300 times slower. >

[GENERAL] Query runs in 335ms; function in 100,239ms : date problem?

2011-09-05 Thread Rory Campbell-Lange
I have a function wrapping a (fairly complex) query. The query itself runs in about a 1/3rd of a second. When running the query as a 'RETURN QUERY' function on Postgres 8.4, the function runs in over 100 seconds, about 300 times slower. The function takes 3 input parameters: 2 dates and a boolean