pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dirk Lutzebaeck <lutzeb@aeccom.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Optimizing ORDER BY with indexes?
Date: Fri, 14 Jan 2000 10:18:16 -0500
Message-ID: <29405.947863096@sss.pgh.pa.us> (raw)
In-Reply-To: <14462.60668.225811.469623@ampato.aeccom.com>
References: <14462.57679.783969.863812@ampato.aeccom.com>
	<14462.60668.225811.469623@ampato.aeccom.com>

Dirk Lutzebaeck <lutzeb@aeccom.com> writes:
> Reading about indexes in the Bowman SQL book I think a 
> _clustered index_ is needed for the problem above.
> Does Postgresql support these?

It's there, but (1) the clustering operation itself isn't really
production-grade code (it tends to drop auxiliary data about the table),
and (2) the optimizer doesn't make any allowance in its estimates for
recently clustered indexes, so it might fail to choose an indexscan when
that would actually be the best way to do things.

I've been thinking about fixing (2), but the problem is to know how long
ago the cluster operation was done --- updates to the table will
gradually destroy the cluster order, so you really want to somehow scale
the cost estimate back towards the unordered case as more and more
updates are done following a cluster.  But that'd mean keeping an update
counter, which is pretty expensive in itself.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <29405.947863096@sss.pgh.pa.us>
Permalink:  ../29405.947863096@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29405.947863096@sss.pgh.pa.us

 · 

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-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lutzeb@aeccom.com
  Subject: Re: [SQL] Optimizing ORDER BY with indexes?
  In-Reply-To: <29405.947863096@sss.pgh.pa.us>
  References: <14462.57679.783969.863812@ampato.aeccom.com> <14462.60668.225811.469623@ampato.aeccom.com> <29405.947863096@sss.pgh.pa.us>

* 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