Search Postgresql Archives

Re: problem with serial

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

 



On Fri, Apr 20, 2012 at 12:19 AM, Yvon Thoraval <yvon.thoraval@xxxxxxxxx> wrote:
> even if i rearrange de sequence by :
>
> "SELECT MAX(rowid) FROM items;";
> "SELECT last_value FROM items_rowid_seq;";
> then if last_value is lower than MAX(rowid) i set it to MAX(rowid) :
> "SELECT setval('items_rowid_seq', max(rowid)) FROM items;";

As a side point, I would recommend against doing this. Once you've
"used" a rowid, it's not worth reusing it. You'll save yourself some
headaches down the track if you simply ignore those odd gaps (ditto
the gaps that result from rolled-back transactions) and just DELETE
the rows you're throwing out without bothering to setval the sequence
back.

ChrisA

-- 
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