Re: return records in DB load order??
От | Bruno Wolff III |
---|---|
Тема | Re: return records in DB load order?? |
Дата | |
Msg-id | 20030614133943.GD27374@wolff.to обсуждение исходный текст |
Ответ на | Re: return records in DB load order?? (Lincoln Yeoh <lyeoh@pop.jaring.my>) |
Список | 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 по дате отправления: