pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Igor Lobanov <ilobanov@swsoft.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Querying distinct values from a large table
Date: Tue, 30 Jan 2007 09:12:51 +0000
Message-ID: <45BF0C13.3070003@archonet.com> (raw)
In-Reply-To: <45BF02DE.7080605@swsoft.com>
References: <45BF02DE.7080605@swsoft.com>

Igor Lobanov wrote:
> Greetings!
> 
> I have rather large table with about 5 millions of rows and a dozen of 
> columns. Let's suppose that columns are named 'a', 'b', 'c' etc. I need 
> to query distinct pairs of ('a';'b') from this table.

> Creating compound index on this table using following statement:
> 
> CREATE INDEX tbl_a_b_idx ON tbl( a, b );
> 
> gives no effect, postgres simply ignores it, at least according to the 
> EXPLAIN output.

What version of PostgreSQL is it?

How many distinct values are you getting back from your 5 million rows? 
If there are too many, an index isn't going to help.

Can you share the EXPLAIN ANALYSE output? You might want to try 
increasing work_mem for this one query to speed any sorting.

How often is the table updated? Clustering might buy you some 
improvements (but not a huge amount I suspect).


   Richard Huxton
   Archonet Ltd



view thread (26+ messages)  latest in thread

Message-ID: <45BF0C13.3070003@archonet.com>
Permalink:  ../45BF0C13.3070003@archonet.com/
Also on:    postgresql.org/message-id/45BF0C13.3070003@archonet.com

 · 

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: dev@archonet.com, ilobanov@swsoft.com
  Subject: Re: Querying distinct values from a large table
  In-Reply-To: <45BF0C13.3070003@archonet.com>

* 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