Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ivan Sergio Borgonovo <mail@xxxxxxxxxxxxxxx> 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.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux