pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <jim@nasby.net>
To: pgsql-performance@postgresql.org
Subject: Poor performance of group by query
Date: Fri, 16 Apr 2004 10:17:06 -0500
Message-ID: <20040416151706.GE87362@nasby.net> (raw)

Anyone have any ideas why this query would be so slow?

stats=# explain analyze SELECT work_units, min(raw_rank) AS rank  FROM Trank_work_overall GROUP BY work_units;
                                                          QUERY PLAN                                                           
-------------------------------------------------------------------------------------------------------------------------------
 HashAggregate  (cost=1050.12..1085.98 rows=14347 width=16) (actual time=163149.981..163227.758 rows=17849 loops=1)
   ->  Seq Scan on trank_work_overall  (cost=0.00..804.41 rows=49141 width=16) (actual time=0.071..328.682 rows=49091 loops=1)
 Total runtime: 163296.212 ms

(3 rows)

stats=# \d Trank_work_overall
Table "pg_temp_1.trank_work_overall"
   Column   |  Type  | Modifiers 
------------+--------+-----------
 raw_rank   | bigint | 
 work_units | bigint | 

stats=# 

FreeBSD fritz.distributed.net 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #1:
Wed Apr  7 18:42:52 CDT 2004
root@fritz.distributed.net:/usr/obj/usr/src/sys/FRITZ  amd64

The machine is a dual opteron with 4G of memory. The query in question
was not hitting the disk at all. PostgreSQL 7.4.2 compiled with -O3.

Also, if I set enable_hashagg = false, it runs in less than a second.
-- 
Jim C. Nasby, Database Consultant                  jim@nasby.net
Member: Triangle Fraternity, Sports Car Club of America
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"



view thread (4+ messages)  latest in thread

Message-ID: <20040416151706.GE87362@nasby.net>
Permalink:  ../20040416151706.GE87362@nasby.net/
Also on:    postgresql.org/message-id/20040416151706.GE87362@nasby.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jim@nasby.net
  Subject: Re: Poor performance of group by query
  In-Reply-To: <20040416151706.GE87362@nasby.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox