Re: cluster index on a table

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Scara Maccai" <m_lists(at)yahoo(dot)it>
Cc: "Greg Stark" <greg(dot)stark(at)enterprisedb(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: cluster index on a table
Date: 2009-07-17 14:14:05
Message-ID: 4A6040DD02000025000288FB@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Scara Maccai <m_lists(at)yahoo(dot)it> wrote:

> - create table mytable as select * from <parent_table> where time
> <in last month> (this gets all the data of last month ordered in the
> "almost" correct order, because all the single tables were
> clustered)

Be sure to include an ORDER BY clause. Without that, there is no
guarantee that even two successive SELECTs from the same table, with
no modifications between, will return rows in the same order. For
example, if someone else starts a query which the planner determines
is best handled with a table scan, and that is still running when you
issue your INSERT/SELECT, your query will join the current scan at
it's point of progress, and "wrap around" when it hits the end. Also,
there would be no guarantee of what order the child tables were read.

-Kevin

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Craig Ringer 2009-07-17 14:29:25 Re: Concurrency issue under very heay loads
Previous Message Matthew Wakeling 2009-07-17 13:40:40 Calling conventions