Re: One Sequence for all tables or one Sequence for each

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: One Sequence for all tables or one Sequence for each
Дата
Msg-id 20050602100330.GB16799@svana.org
обсуждение исходный текст
Ответ на Re: One Sequence for all tables or one Sequence for each  (Kaloyan Iliev Iliev <news1@faith.digsys.bg>)
Ответы Re: One Sequence for all tables or one Sequence for each  (Janning Vygen <vygen@gmx.de>)
Список pgsql-general
On Thu, Jun 02, 2005 at 12:58:33PM +0300, Kaloyan Iliev Iliev wrote:
> Hi,
>
> I suppose the paralel work will be a problem if you are using one
> sequence for all tables. If you insert a large amount of rows in
> different tables there will be great slowdown because your sequence is
> the bottle neck of your database. All the inserts must read from it one
> by one. If you have many sequences (one for each table PK) every insert
> in a different table will use different sequence and this will improve
> performance.

I don't know about this. Sequences are designed to be very efficient,
they don't rollback and can be cached by backends.

In several of the databases I setup, I sometimes arranged for sequences
to start at different points so when you setup a foreign key there was
no chance you linked it to the wrong table. This especially in cases
where there might be confusion about which table links where.

Using one serial for everything does this even better. As for
performance, I think disk I/O is going to be an issue before getting
sequence numbers will be...
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения

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

Предыдущее
От: Tino Wildenhain
Дата:
Сообщение: Re: writing a file using procedure
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: writing a file using procedure