|
Posted by newtophp2000 on 06/20/06 11:41
Alexander Kuznetsov wrote:
> > declare @next int
> > begin transaction
> > update my_sequence set seq = seq + 1 where name = 'abc';
> > select @next = seq from my_sequence where name = 'abc';
> > commit transaction
> >
>
> If you can consume numbers in batches, do it, as it is dramatically
> more efficient. For instance, if you know up front that you need 100
> numbers, do this:
>
> update my_sequence set seq = seq + 100 where name = 'abc';
> select @next = seq - 99 from my_sequence where name = 'abc';
This looks interesting. A suggestion that was very similar to this one
came up a while ago in our project. As I remember, the developers did
not like the idea as it introduced more work for them to manage.
Thanks for the tip!
Navigation:
[Reply to this message]
|