Re: sequence not restarting in a for loop (actually semi-random numbers)

Поиск
Список
Период
Сортировка
От Ivan Sergio Borgonovo
Тема Re: sequence not restarting in a for loop (actually semi-random numbers)
Дата
Msg-id 20081112180153.370326b7@dawn.webthatworks.it
обсуждение исходный текст
Ответ на Re: sequence not restarting in a for loop (actually semi-random numbers)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Wed, 12 Nov 2008 11:17:03 -0500
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Ivan Sergio Borgonovo <mail@webthatworks.it> writes:
> >   insert into mytop (id,n) select id, nextval('tmp_seq')
> >     from biglist join mylist on biglist.id=mylist
> >     order by biglist.something limit 3;
>
> I suspect you are expecting the nextval()s to be done after the
> LIMIT, but actually they'll most likely be done before it, ie
> you're getting a lot of unintended nextvals happening.  Try doing
> the ORDER BY/LIMIT in a sub-select.

Thanks. That did it.

I think I've seen similar replies before... but I couldn't relate
them to my problem.

I'd do like Bart Simpson: order by, limit, nextval, sequence, order
by, limit, nextval, sequence...
so that this answer will be well indexed ;)

--
Ivan Sergio Borgonovo
http://www.webthatworks.it


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

Предыдущее
От: Robert Fitzpatrick
Дата:
Сообщение: Post to another db using pl/pgsql
Следующее
От: tv@fuzzy.cz
Дата:
Сообщение: Re: Post to another db using pl/pgsql