pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: adrobj <adrobj@yahoo.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Clustered/covering indexes (or lack thereof :-)
Date: Fri, 16 Nov 2007 11:34:36 -0800
Message-ID: <1195241676.22428.218.camel@dogma.ljc.laika.com> (raw)
In-Reply-To: <13700848.post@talk.nabble.com>
References: <13700848.post@talk.nabble.com>

On Sun, 2007-11-11 at 22:59 -0800, adrobj wrote:
> This is probably a FAQ, but I can't find a good answer...
> 
> So - are there common techniques to compensate for the lack of
> clustered/covering indexes in PostgreSQL? To be more specific - here is my
> table (simplified):
> 
> topic_id int
> post_id int
> post_text varchar(1024)
> 
> The most used query is: SELECT post_id, post_text FROM Posts WHERE
> topic_id=XXX. Normally I would have created a clustered index on topic_id,
> and the whole query would take ~1 disk seek.
> 
> What would be the common way to handle this in PostgreSQL, provided that I
> can't afford 1 disk seek per record returned?
> 

Periodically CLUSTER the table on the topic_id index. The table will not
be perfectly clustered at all times, but it will be close enough that it
won't make much difference.

There's still the hit of performing a CLUSTER, however.

Another option, if you have a relatively small number of topic_ids, is
to break it into separate tables, one for each topic_id.

Regards,
	Jeff Davis




view thread (4+ messages)  latest in thread

Message-ID: <1195241676.22428.218.camel@dogma.ljc.laika.com>
Permalink:  ../1195241676.22428.218.camel@dogma.ljc.laika.com/
Also on:    postgresql.org/message-id/1195241676.22428.218.camel@dogma.ljc.laika.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: pgsql@j-davis.com, adrobj@yahoo.com
  Subject: Re: Clustered/covering indexes (or lack thereof :-)
  In-Reply-To: <1195241676.22428.218.camel@dogma.ljc.laika.com>
  References: <13700848.post@talk.nabble.com> <1195241676.22428.218.camel@dogma.ljc.laika.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