X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6BC71D1E934 for ; Tue, 23 Mar 2004 20:32:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 73943-01 for ; Tue, 23 Mar 2004 16:32:09 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 3801FD1E2E2 for ; Tue, 23 Mar 2004 16:32:07 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2NKW8N6028367; Tue, 23 Mar 2004 15:32:08 -0500 (EST) To: "A Palmblad" Cc: "Postgres Performance" Subject: Re: SLOW query with aggregates In-reply-to: <003201c41111$f4dc96f0$97019696@AERS04> References: <003201c41111$f4dc96f0$97019696@AERS04> Comments: In-reply-to "A Palmblad" message dated "Tue, 23 Mar 2004 12:03:48 -0800" Date: Tue, 23 Mar 2004 15:32:08 -0500 Message-ID: <28366.1080073928@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/324 X-Sequence-Number: 6180 "A Palmblad" writes: > GroupAggregate (cost=0.00..338300.34 rows=884 width=345) (actual > time=86943.272..382718.104 rows=3117 loops=1) > -> Merge Join (cost=0.00..93642.52 rows=1135610 width=345) (actual > time=0.148..24006.748 rows=1120974 loops=1) You do not have a planning problem here, and trying to change the plan is a waste of time. The slowness is in the actual computation of the aggregate functions; ergo the only way to speed it up is to change what you're computing. What aggregates are you computing exactly, and over what datatypes? regards, tom lane