pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Simon Riggs <simon@2ndquadrant.com>
To: Igor Lobanov <ilobanov@swsoft.com>
Cc: Richard Huxton <dev@archonet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Querying distinct values from a large table
Date: Tue, 30 Jan 2007 14:04:15 +0000
Message-ID: <1170165856.3681.54.camel@silverbirch.site> (raw)
In-Reply-To: <45BF10D7.3040203@swsoft.com>
References: <45BF02DE.7080605@swsoft.com>
	<45BF0C13.3070003@archonet.com>
	<45BF10D7.3040203@swsoft.com>

On Tue, 2007-01-30 at 15:33 +0600, Igor Lobanov wrote:

> explain analyze select distinct a, b from tbl
> 
> EXPLAIN ANALYZE output is:
> 
>   Unique  (cost=500327.32..525646.88 rows=1848 width=6) (actual 
> time=52719.868..56126.356 rows=5390 loops=1)
>     ->  Sort  (cost=500327.32..508767.17 rows=3375941 width=6) (actual 
> time=52719.865..54919.989 rows=3378864 loops=1)
>           Sort Key: a, b
>           ->  Seq Scan on tbl  (cost=0.00..101216.41 rows=3375941 
> width=6) (actual time=16.643..20652.610 rows=3378864 loops=1)
>   Total runtime: 57307.394 ms

All your time is in the sort, not in the SeqScan.

Increase your work_mem.

-- 
  Simon Riggs             
  EnterpriseDB   http://www.enterprisedb.com





view thread (26+ messages)  latest in thread

Message-ID: <1170165856.3681.54.camel@silverbirch.site>
Permalink:  ../1170165856.3681.54.camel@silverbirch.site/
Also on:    postgresql.org/message-id/1170165856.3681.54.camel@silverbirch.site

 · 

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: simon@2ndquadrant.com, ilobanov@swsoft.com, dev@archonet.com
  Subject: Re: Querying distinct values from a large table
  In-Reply-To: <1170165856.3681.54.camel@silverbirch.site>

* 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