Re: [PERFORM] unexpected stable function behavior

2011-03-15 Thread Julius Tuskenis
Hello, 2011.03.14 15:41, Merlin Moncure rašė: WITH results as ( SELECT distinct price_id as price_id FROM ticket_price JOIN ticket_has_ticket_price ON (price_id = thtp_price_id) WHERE price_event_id = 7820 and (current_timestamp= price_date AND current_timestamp= price_date_till) )

Re: [PERFORM] unexpected stable function behavior

2011-03-15 Thread Julius Tuskenis
Thank you, Tom for you answer 2011.03.14 19:17, Tom Lane rašė: That function property*allows* the optimizer to invoke the function fewer times than would happen in an un-optimized query. It does not*require* it to do so. Thank you for clearing that for me. I think these 2 sentences in

Re: [PERFORM] unexpected stable function behavior

2011-03-14 Thread Merlin Moncure
On Mon, Mar 14, 2011 at 3:46 AM, Julius Tuskenis jul...@nsoft.lt wrote: Hello, Merlin Thank you for your quick response. 2011.03.10 23:14, Merlin Moncure rašė: This is a huge problem with non trivial functions in the select list. Pushing the result into and a subquery does NOT guarantee

Re: [PERFORM] unexpected stable function behavior

2011-03-14 Thread Andres Freund
On Thursday, March 10, 2011 05:26:00 PM Julius Tuskenis wrote: 3) As STABLE function should be executed once for every different set of parameters Thats not true. Thats not what any of the volatility information (like STABLE, IMMUTABLE, VOLATILE) does. See

Re: [PERFORM] unexpected stable function behavior

2011-03-14 Thread Julius Tuskenis
Hello, Merlin Thank you for your quick response. 2011.03.10 23:14, Merlin Moncure rašė: This is a huge problem with non trivial functions in the select list. Pushing the result into and a subquery does NOT guarantee that the inner result is materialized first. From the postgresql documentation

Re: [PERFORM] unexpected stable function behavior

2011-03-14 Thread Tom Lane
Julius Tuskenis jul...@nsoft.lt writes: From the postgresql documentation about STABLE functions: This category allows the optimizer to optimize multiple calls of the function to a single call. I thought that this means that optimizer executes the function only for now parameter sets and

[PERFORM] unexpected stable function behavior

2011-03-10 Thread Julius Tuskenis
Hello, list Our company is creating a ticketing system. Of course the performance issues are very important to us (as to all of you I guess). To increase speed of some queries stable functions are used, but somehow they don't act exactly as I expect, so would you please explain what am I

Re: [PERFORM] unexpected stable function behavior

2011-03-10 Thread Merlin Moncure
On Thu, Mar 10, 2011 at 10:26 AM, Julius Tuskenis jul...@nsoft.lt wrote: Hello, list Our company is creating a ticketing system. Of course the performance issues are very important to us (as to all of you I guess). To increase speed of some queries stable functions are used, but somehow they