Re: Getting sequence-generated IDs from multiple row insert

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: Getting sequence-generated IDs from multiple row insert
Дата
Msg-id 1396298044794-5798107.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Getting sequence-generated IDs from multiple row insert  (Andrew Sullivan <ajs@crankycanuck.ca>)
Ответы Re: Getting sequence-generated IDs from multiple row insert  (Andrew Sullivan <ajs@crankycanuck.ca>)
Список pgsql-general
Andrew Sullivan-8 wrote
>> So currently I've changed my code to use RETURNING and then I'm ordering
>> the results based on a secondary column that I know the order of. This
>> works, but seems clunky, so I'm wondering if there's a nicer way.
>
> This is probably what I'd do, assuming that "further processing" isn't
> more data transformation.  If it _is_, then I'd do the whole thing in
> a single step (in the database, once I inserted).

If order is an implicit property of the source data then you need to
explicitly encode that order during (or before) import.  There are numerous
ways to implement such but except for extremely simple cases PostgreSQL will
not do the appropriate thing automatically in the face of concurrency.

Also, do you need sequential IDs or just IDs that are ever increasing?  And
if the later then tagging the input source will let you distinguish between
two different datasets even if their sequences are overlapping.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Getting-sequence-generated-IDs-from-multiple-row-insert-tp5798092p5798107.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: Si Chen
Дата:
Сообщение: Re: getting the current query from pg_stat_activity
Следующее
От: Edson Richter
Дата:
Сообщение: Re: Why does "checkpointer" is consumig ~1.2Gb of RAM?