Re: return records in DB load order??

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
Cc: Maksim Likharev <mlikharev(at)aurigin(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: return records in DB load order??
Date: 2003-06-14 13:39:43
Message-ID: 20030614133943.GD27374@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jun 14, 2003 at 11:00:43 +0800,
Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my> wrote:
> At 12:35 PM 6/13/2003 -0700, Maksim Likharev wrote:
>
> >Hi,
> >if I'd like to return records in DB load order, will it be enough to say
> >
> >
> >SELECT .....
> >ORDER BY oid?
> >
> >basically I assume that lowest oid will be for early records?
>
> How about using the "serial" type instead?

This is a bad idea. Sequences aren't gaurenteed to be monotonicly
increasing over time except within a single session. (And of course
that nobody is using setval.) If you make sure that sequence values
are given out to backends one at a time, this will mostly work.

You still have to worry about what is meant by DB load order. Is
that when a transaction starts, ends or the time a particular row
is written in the middle of a transaction. If it is transaction start
time, you can use now(). If it is when the row is written, then you can
use timeofday(). I don't think there is a good way to get end of
transaction time. I think to get close to that you would want to use
timeofday() and write the record just before committing the transaction.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-06-14 13:45:33 Re: Growing Database Size
Previous Message Bruno Wolff III 2003-06-14 13:27:20 Re: Index not being used in MAX function (7.2.3)