>
> The easiest solution is to use a file on the file system, though that has
> problems with scalability. A better solution is probably to have a table in
> your DB like this:
>
> Create table keyGenerator (
> table char(30), /* fixed width for speed */
> currentMaxKey int unsigned not null,
> primary key (table)
> );
>
> Then make a function stored in the application scope (if you're on CFMX)
> which takes a table name and returns the next available key, incrementing
> the database's value as well. Inside the function use an exclusive named
> lock so you don't get duplicates returned. Do NOT put the call to it inside
> your CFTRANSACTION block. You you need zero concurrency for that table, and
> transactions are designed to do exactly the opposite.
But you need Atomicity and/or Isolation (reading the last value
and incrementing it are 2 different actions that need to be
somehow grouped), so you still need a transaction. But if you go
for a HEAP table which you build on application start, the
overhead should be far less.
Jochem
--
I don't get it
immigrants don't work
and steal our jobs
- Loesje
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

