Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLyqR-0003E2-So for pgsql-performance@postgresql.org; Wed, 10 Oct 2012 16:09:16 +0000 Received: from forward14.mail.yandex.net ([2a02:6b8:0:801::4]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLyqJ-0005pi-H1 for pgsql-performance@postgresql.org; Wed, 10 Oct 2012 16:09:15 +0000 Received: from web16f.yandex.ru (web16f.yandex.ru [95.108.131.157]) by forward14.mail.yandex.net (Yandex) with ESMTP id 2C9191983725 for ; Wed, 10 Oct 2012 20:09:04 +0400 (MSK) Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by web16f.yandex.ru (Yandex) with ESMTP id E75DC21004B; Wed, 10 Oct 2012 20:09:03 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1349885344; bh=AEPg/WBODXNnAfUniRvn3iNK16Si/rF3hkU0ltI+gZs=; h=From:To:Subject:MIME-Version:Message-Id:Date: Content-Transfer-Encoding:Content-Type; b=a5xL32X8XU2Ri+UT1tBKqlrMkpqPKRbi0769abryYA3UBHtPmOhr+jaqWfcvkCTry b/QF3eURfgp+domOzToAg32RNrXva9bkHwGFYStpPG74xz5ricuzO7TzDugdREPAn2 nehJiM7xJiy4worXysnF+VcCVh8SHcJaLBwluO0g= Received: from [188.168.10.0] ([188.168.10.0]) by web16f.yandex.ru with HTTP; Wed, 10 Oct 2012 20:09:02 +0400 From: Korisk To: pgsql-performance@postgresql.org Subject: hash aggregation MIME-Version: 1.0 Message-Id: <118871349885342@web16f.yandex.ru> Date: Wed, 10 Oct 2012 20:09:02 +0400 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Pg-Spam-Score: -2.0 (--) X-Archive-Number: 201210/119 X-Sequence-Number: 48078 Hello! Is it possible to speed up the plan? hashes=# \d hashcheck Table "public.hashcheck" Column | Type | Modifiers --------+-------------------+-------------------------------------------------------- id | integer | not null default nextval('hashcheck_id_seq'::regclass) name | character varying | value | character varying | Indexes: "btr" btree (name) hashes=# select version(); version -------------------------------------------------------------------------------------------------------------- PostgreSQL 9.2.1 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2), 64-bit (1 row) hashes=# explain analyse verbose select name, count(name) as cnt from hashcheck group by name order by name desc; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=573977.88..573978.38 rows=200 width=32) (actual time=10351.280..10351.551 rows=4000 loops=1) Output: name, (count(name)) Sort Key: hashcheck.name Sort Method: quicksort Memory: 315kB -> HashAggregate (cost=573968.24..573970.24 rows=200 width=32) (actual time=10340.507..10341.288 rows=4000 loops=1) Output: name, count(name) -> Seq Scan on public.hashcheck (cost=0.00..447669.16 rows=25259816 width=32) (actual time=0.019..2798.058 rows=25259817 loops=1) Output: id, name, value Total runtime: 10351.989 ms (9 rows) hashes=# Thank you.