Re: return records in DB load order?? - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: return records in DB load order??
Date
Msg-id 20030614133943.GD27374@wolff.to
Whole thread Raw
In response to Re: return records in DB load order??  (Lincoln Yeoh <lyeoh@pop.jaring.my>)
List pgsql-general
On Sat, Jun 14, 2003 at 11:00:43 +0800,
  Lincoln Yeoh <lyeoh@pop.jaring.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.




pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Index not being used in MAX function (7.2.3)
Next
From: Bruno Wolff III
Date:
Subject: Re: Growing Database Size