MaRcElO PeReIrA writes:
> How can I assure a ''sequence WITHOUT holes''?
> $ SELECT max(prod_id)+1 FROM products;
You can do that, but
SELECT prod_id FROM products ORDER BY prod_id DESC LIMIT 1;
will be faster. In fact, if you have a B-tree index on prod_id (which you
should), it will be nearly constant time.
Also, make sure if you do a SELECT, then some client application logic,
then an UPDATE, to do it in one transaction and use the appropriate
isolation level, locking, etc.
--
Peter Eisentraut peter_e@gmx.net