Re: [PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-18 Thread Anish Kejariwal
Hi Craig, Fair point. For now, I mean just fast - which is 5-15 seconds, but I'd like to get it down to the 1-2 second range. From the query I provided, I have approximately 30,000 unique keys (what I called primary_id) that I'm grouping by, and each key has a series of numerical values for

[PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-17 Thread Anish Kejariwal
Hi everyone, I'm using postgres 9.0.3, and here's the OS I'm running this on: Linux 2.6.18-238.12.1.el5xen #1 SMP Tue May 31 14:02:29 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux I have a fairly straight forward query. I'm doing a group by on an ID, and then calculating some a statistic on the

Re: [PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-17 Thread Pavel Stehule
Hello 2011/8/17 Anish Kejariwal anish...@gmail.com: Hi everyone, I'm using postgres 9.0.3, and here's the OS I'm running this on: Linux 2.6.18-238.12.1.el5xen #1 SMP Tue May 31 14:02:29 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux I have a fairly straight forward query.  I'm doing a group by on

Re: [PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-17 Thread Anish Kejariwal
Thanks Pavel! that definitely solved it. Unfortunately, the function I gave you was a simple/short version of what the actual function is going to be. The actual function is going to get parameters passed to it, and based on the parameters will go through some if...else conditions, and maybe

Re: [PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-17 Thread Pavel Stehule
2011/8/17 Anish Kejariwal anish...@gmail.com: Thanks Pavel! that definitely solved it. Unfortunately, the function I gave you was a simple/short version of what the actual function is going to be.  The actual function is going to get parameters passed to it, and based on the parameters will go

Re: [PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-17 Thread Craig Ringer
On 18/08/2011 3:00 AM, Anish Kejariwal wrote: Thanks Pavel! that definitely solved it. Unfortunately, the function I gave you was a simple/short version of what the actual function is going to be. The actual function is going to get parameters passed to it, and based on the parameters will

Re: [PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-17 Thread Anish Kejariwal
Thanks for the help Pavel and Craig. I really appreciate it. I'm going to try a couple of these different options (write a c function, use a sql function with case statements, and use plperl), so I can see which gives me the realtime performance that I need, and works best for clean code in my

Re: [PERFORM] Calculating statistic via function rather than with query is slowing my query

2011-08-17 Thread Craig Ringer
On 18/08/2011 9:03 AM, Anish Kejariwal wrote: Thanks for the help Pavel and Craig. I really appreciate it. I'm going to try a couple of these different options (write a c function, use a sql function with case statements, and use plperl), so I can see which gives me the realtime performance