Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread Tom Lane
Stephen Frost writes: > * S G (sgennar...@gmail.com) wrote: >> I guess to really get down to the issue, I'm curious if what I'm doing is >> considered 'standard procedure' to others-- i.e. using funny workarounds >> like building the query in a text var and executing it with plpgsql's RETURN >> QU

Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread S G
> > It would help if you post the output from EXPLAIN ANALYZE for each case, > as this will hopefully show where the bottleneck is. > I'm glad you asked, and I think I've discussed enough about what *could-be* happening that I'd like to get my hands dirty with what's really going on. Maybe now I c

Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread S G
> I wrote a blog article about this: Google for "Why is my function > slow?" Greg, great article. It's funny and humbling how I thought I'd invented the wheel with this workaround, but now it suddenly appears to be common practice. I guess I'm

Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread Stephen Frost
S G, * S G (sgennar...@gmail.com) wrote: > I guess to really get down to the issue, I'm curious if what I'm doing is > considered 'standard procedure' to others-- i.e. using funny workarounds > like building the query in a text var and executing it with plpgsql's RETURN > QUERY EXECUTE command.

Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 > Also re: Raymond's request, I tried humoring myself with the EXPLAIN output, > and I actually don't see anything useful-looking at all when I run it on a > stored function like I'm using. Is there any way to utilize EXPLAIN on a > query embed

Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread S G
Thanks Stephen, that makes a lot of sense based on some research I was doing yesterday. I'm still a bit green to understand the inner workings of the planner and all the stuff coming out of EXPLAIN, but I'm definitely trying to keep it all in mind as I progress at this stuff. I guess to really ge

Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread Stephen Frost
S G, * S G (sgennar...@gmail.com) wrote: > Can anyone lend a guess as to what I'm running into here, or do I need to > provide more specifics to recreate the issue? It's repeatable, but it's a > fair bit of data for me to just post in here as-is. I've already discovered > a few creative workarou

Re: [GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread Raymond O'Donnell
On 13/05/2010 16:59, S G wrote: > Can anyone lend a guess as to what I'm running into here, or do I need > to provide more specifics to recreate the issue? It's repeatable, but > it's a fair bit of data for me to just post in here as-is. I've already > discovered a few creative workarounds (e.g.

[GENERAL] SQL code runs slower as a stored function

2010-05-13 Thread S G
Hi all, It's my first time posting to the list, though it's helped me through numerous jams throughout the past year as I've been familiarizing myself with all of the wonderful postgresisms =) Just yesterday, I made what I thought would be a very minor and routine modification to a stored functio