Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-18 Thread Marti Raudsepp
On Mon, Sep 12, 2011 at 00:22, Tom Lane t...@sss.pgh.pa.us wrote: The other thing that is going to be an issue is that I'm fairly sure this breaks plpgsql's handling of simple expressions. The quick and dirty solution to this would be for plpgsql to pass some kind of planner flag that

Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-12 Thread Marti Raudsepp
On Mon, Sep 12, 2011 at 00:22, Tom Lane t...@sss.pgh.pa.us wrote: Well, people seem to think that this is worth pursuing, so here's a couple of thoughts about what needs to be done to get to something committable. Thanks, that's exactly the kind of feedback I need. IMO this is no good

Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-12 Thread Tom Lane
Marti Raudsepp ma...@juffo.org writes: On Mon, Sep 12, 2011 at 00:22, Tom Lane t...@sss.pgh.pa.us wrote: type CacheExpr (that's just the first name that came to mind, maybe somebody has a better idea) StableConstExpr? But we can leave the bikeshedding for later :) Well, FWIW, I found that

Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-11 Thread Tom Lane
Marti Raudsepp ma...@juffo.org writes: On Sun, Sep 11, 2011 at 01:51, Tom Lane t...@sss.pgh.pa.us wrote: The patch as given has a bunch of implementation issues This is my first patch that touches the more complicated internals of Postgres. I'm sure I have a lot to learn. :) Well, people

[HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-10 Thread Marti Raudsepp
Hi, This is a proof of concept patch for recognizing stable function calls with constant arguments and only calling them once per execution. I'm posting it to the list to gather feedback whether this is a dead end or not. Last time when this was brought up on the list, Tom Lane commented that

Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-10 Thread Tom Lane
Marti Raudsepp ma...@juffo.org writes: This is a proof of concept patch for recognizing stable function calls with constant arguments and only calling them once per execution. I'm posting it to the list to gather feedback whether this is a dead end or not. Hmm. This is an interesting hack,

Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-10 Thread Josh Berkus
The patch as given has a bunch of implementation issues, but I think it's close enough for crude performance testing, and your numbers do show a potential performance benefit. The question that I think is unresolved is whether the set of cases covered is wide enough to be useful in

Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-10 Thread Josh Berkus
If I understand the limitations correctly, though, what this would do is cause functions to perform substantially differently if called with expressions as arguments instead of text constants, no? Seems like that would lead to some user confusion. Although, with stuff like now(), we

Re: [HACKERS] [WIP] Caching constant stable expressions per execution

2011-09-10 Thread Marti Raudsepp
On Sun, Sep 11, 2011 at 01:51, Tom Lane t...@sss.pgh.pa.us wrote: Usually what people have meant when they ask for function caching is that multiple executions of a given stable function with the same argument values be folded to just one execution. In the general case that would require some