Re: [PERFORM] Optimizing query

2010-11-26 Thread pasman pasmański
Thanks for reply. First query: SELECT R."Osoba weryfikująca" AS "Osoba", R."LP"::text AS "Sprawa", A."NKA", A."NTA", Sum(A."Ile")::text AS "Ilość CDR" FROM ONLY "NumeryA" A LEFT JOIN "Rejestr stacji do naprawy" R ON A."NKA" = R."Numer kierunkowy" and A."NTA" like R."Numer stacji" and

Re: [PERFORM] Optimizing query

2010-11-26 Thread Pierre C
Note that your LEFT JOIN condition is probably quite slow... Please post EXPLAIN ANALYZE for this simplified version : SELECT R."Osoba weryfikuj?ca", R."LP", A."NKA", A."NTA", Sum("Ile") FROM"NumeryA" A LEFT JOIN "Rejestr stacji do napr

[PERFORM] Optimizing query

2010-11-24 Thread pasman pasmański
Hello. I have a query which works a bit slow. It's runned on desktop computer: AMD Athlon X2 2GHz , Win Xp sp2, 1GB ram. Postgres 8.4.5 with some changes in config: shared_buffers = 200MB # min 128kB # (change requires restart) temp_buffers = 8MB

Re: [PERFORM] Optimizing query

2010-10-07 Thread Srikanth K
Sorry to forget to give the postgres version as 8.1 On Thu, Oct 7, 2010 at 2:12 PM, Srikanth K wrote: > Hi Can u Please let me know how can i optimize this query better. As i am > attaching u the Query, Schema and Explain Analyze Report. > > Plerase help me in optimizing this query. > > select >

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-29 Thread Doug Cole
On Thu, Oct 22, 2009 at 6:22 AM, Kenneth Marshall wrote: > On Wed, Oct 21, 2009 at 03:51:25PM -0700, Doug Cole wrote: >> I have a reporting query that is taking nearly all of it's time in aggregate >> functions and I'm trying to figure out how to optimize it.  The query takes >> approximately 170m

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-26 Thread Marc Mamin
..@postgresql.org [mailto:pgsql-performance-ow...@postgresql.org] On Behalf Of Nikolas Everett Sent: Thursday, October 22, 2009 4:48 AM To: Doug Cole Cc: pgsql-performance Subject: Re: [PERFORM] optimizing query with multiple aggregates So you've got a query like: SELECT SUM(CASE WHEN fie

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-22 Thread Scott Carey
On 10/21/09 3:51 PM, "Doug Cole" wrote: > I have a reporting query that is taking nearly all of it's time in aggregate > functions and I'm trying to figure out how to optimize it.  The query takes > approximately 170ms when run with "select *", but when run with all the > aggregate functions t

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-22 Thread Robert Haas
On Wed, Oct 21, 2009 at 10:21 PM, Doug Cole wrote: > On Wed, Oct 21, 2009 at 5:39 PM, Merlin Moncure wrote: >> >> On Wed, Oct 21, 2009 at 6:51 PM, Doug Cole wrote: >> > I have a reporting query that is taking nearly all of it's time in >> > aggregate >> > functions and I'm trying to figure out

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-22 Thread Kenneth Marshall
On Wed, Oct 21, 2009 at 03:51:25PM -0700, Doug Cole wrote: > I have a reporting query that is taking nearly all of it's time in aggregate > functions and I'm trying to figure out how to optimize it. The query takes > approximately 170ms when run with "select *", but when run with all the > aggrega

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-21 Thread Nikolas Everett
So you've got a query like: SELECT SUM(CASE WHEN field >= 0 AND field < 10 THEN 1 ELSE 0 END) as zeroToTen, SUM(CASE WHEN field >= 10 AND field < 20 THEN 1 ELSE 0 END) as tenToTwenty, SUM(CASE WHEN field >= 20 AND field < 30 THEN 1 ELSE 0 END) as tenToTwenty, ... FROM b

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-21 Thread David Wilson
On Wed, Oct 21, 2009 at 6:51 PM, Doug Cole wrote: > > repeated across many different x,y values and fields to build out several > histograms of the data. The main culprit appears to be the CASE statement, > but I'm not sure what to use instead. I'm sure other people have had > similar queries a

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-21 Thread Doug Cole
On Wed, Oct 21, 2009 at 5:39 PM, Merlin Moncure wrote: > > On Wed, Oct 21, 2009 at 6:51 PM, Doug Cole wrote: > > I have a reporting query that is taking nearly all of it's time in aggregate > > functions and I'm trying to figure out how to optimize it.  The query takes > > approximately 170ms whe

Re: [PERFORM] optimizing query with multiple aggregates

2009-10-21 Thread Merlin Moncure
On Wed, Oct 21, 2009 at 6:51 PM, Doug Cole wrote: > I have a reporting query that is taking nearly all of it's time in aggregate > functions and I'm trying to figure out how to optimize it.  The query takes > approximately 170ms when run with "select *", but when run with all the > aggregate funct

[PERFORM] optimizing query with multiple aggregates

2009-10-21 Thread Doug Cole
I have a reporting query that is taking nearly all of it's time in aggregate functions and I'm trying to figure out how to optimize it. The query takes approximately 170ms when run with "select *", but when run with all the aggregate functions the query takes 18 seconds. The slowness comes from o

[PERFORM] optimizing query performance

2008-03-31 Thread Frits Hoogland
Hi! I've got the following statement: SELECT DISTINCT sub.os, COUNT(sub.os) as total FROM ( SELECT split_part(system.name, ' ', 1) as os FROM system, attacks WHERE 1 = 1 AND timestamp >= 1205708400 AND timestamp <= 120631320