| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: NextNumbers Tables
"Jason W. Paul" <nobody_at_nowhere.com> wrote in
news:3e49a868$0$99433$a04e5680_at_nnrp.fuse.net:
>
>> >> If you want to do it that way, I'd go for the first approach. >> Just on caveat: The way to go is first increment the number then select
>> Otherwise, you'll run into trouble in a multiuser environment where two >> users want to insert at the same time.
Which DBMS's are you thinking about?
For Oracle, Sybase ASE and SQL Server, the UPDATE in tx #1 will block the UPDATE in tx #2
With Oracle, you can do it one of two ways:
With Sybase ASE and SQL Server you can do it one of two ways as well:
UPDATE mytable
set @my_next_val = next_val,
next_val = next_val + 1
...
> FYI -- I disagree with this method entirely as it will, in high volume
> environments, create severe "hotspots" on these tables. If you don't
> have high volume, it might not be an issue.
To some extent I agree. With Oracle, I'd rather use SEQUENCES and with Sybase ASE I'd rather use the IDENTITY data type and the equivalent with SQL Server.
Alternatively, one can implement a next_val table and have batches of values for each 'SPID' within ASE and SQL Server. This way you avoid the hotspot issue.
-- Pablo Sanchez, High-Performance Database Engineering http://www.hpdbe.comReceived on Tue Feb 11 2003 - 22:15:07 CST
![]() |
![]() |