dbTalk Databases Forums  

Auto generated sequences

comp.databases.ingres comp.databases.ingres


Discuss Auto generated sequences in the comp.databases.ingres forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
nikosv
 
Posts: n/a

Default Auto generated sequences - 02-02-2009 , 07:05 AM






can someone shed more light into the new feature of auto generated
sequences?
are they just for convenience or do they eliminate the concurrency
issues associated with
unique key generation? because I see that they take logical locks

is it possible to introduce gaps between the sequence by means of
server failure, aging out of the shared pool in case of caching, or
programatically?

Reply With Quote
  #2  
Old   
Martin Bowes
 
Posts: n/a

Default Re: [Info-Ingres] Auto generated sequences - 02-02-2009 , 07:50 AM






Hi Niko,

Quote:
are they just for convenience or do they eliminate the concurrency
issues associated with unique key generation?
Because I see that they take logical locks.
There certainly convenient, and less prone to lock problems. The
sequence largely lives in the server itself so a logical lock is taken
in there. So speed of access should be dramatic...unless of course you
set the nocache options.

Quote:
Is it possible to introduce gaps between the sequence by means of
server failure, aging out of the shared pool in case of caching,
or programatically?
Yes to all the above. But quite frankly gapless sequences are just not
worth the hassle.

Martin Bowes



Reply With Quote
  #3  
Old   
Roy Hann
 
Posts: n/a

Default Re: Auto generated sequences - 02-03-2009 , 06:53 AM



nikosv wrote:

Quote:
can someone shed more light into the new feature of auto generated
sequences?
are they just for convenience or do they eliminate the concurrency
issues associated with
unique key generation? because I see that they take logical locks
I wouldn't say they eliminate concurrency issues. They certainly reduce
the risk of lock contention (and hence queueing) on the last-value
table. For the knowledgeable programmer the benefit is just the
convenience of not having to write the small amount of code needed
to generate values. The big winners are the naive programmers who
didn't even know there was a problem.

But contention on the state table is only part of the problem.
Using monotonic physical key values to insert into a B-tree or an ISAM
table is still a massive concurrency problem in a busy system. You can
relieve it somewhat by using row-level locking, but there's limits to
how far even row-level locking will scale, and there is no guarantee you
will get row-level locking even if you ask for it.

Ingres Database 9.3 includes (or soon will include) "unordered"
sequences, which supply unique values in non-sequential order.
Using these values as physical keys will effectively randomize insertion
into B-trees and ISAM tables, eliminating concurrency problems.

Quote:
is it possible to introduce gaps between the sequence by means of
server failure, aging out of the shared pool in case of caching, or
programatically?
You certainly still run the risk of gaps. But gapless sequences are a
perforance killer no matter how you generate the values. You can't
allocate the next value until the previous value has been used AND
committed. That makes your system essentially single-user. It will not
scale at all. The preferred solution (preferred by the programmer if
not the business) is auditable numbers. You generate a block of
numbers and store their current disposition in a table in the database;
you dole them out as a separate operation as needed. You don't
insist on using them up in strict order, but you do require them to be
traceable, so that you can supply information like: the numbers 9, 10,
11, and 12 have been generated, and the numbers 9,10, and 12 have been
used (and committed), but 11 is still in the pool waiting to be used,
and will be used before we generate another block of numbers.

The one time I have had to deal with genuinely in-order gapless
numbers in real life was when I was outputting onto pre-printed
certificates that already had a serial number, and I had to know the
number of each certificate I was printing. But in that case the
numbers were really a natural key. (The same problem arises with
pre-printed cheques.) But happily those are both single-user jobs so no
problem. Other than that, the need for gapless numbering is rare, I
find. If your users are trying to tell you different, I'd ask them
some hard questions before meekly giving in to their request.

--
Roy

UK Ingres User Association Conference 2009 will be on Tuesday June 9, 2009
Go to http://www.iua.org.uk/join to get on the mailing list.




Reply With Quote
  #4  
Old   
rhill@hillconsult.com
 
Posts: n/a

Default [Info-Ingres] For Roy - 02-03-2009 , 12:02 PM





Roy:

I need to contact you. Could you email me please?

Thanks
Roger
****************************************
Roger Hill
****************************************


Reply With Quote
  #5  
Old   
Roy Hann
 
Posts: n/a

Default Re: [Info-Ingres] For Roy - 02-03-2009 , 11:49 PM



rhill (AT) hillconsult (DOT) com wrote:

Quote:
Roy:

I need to contact you. Could you email me please?
Hi Rog. Done.

--
Roy

UK Ingres User Association Conference 2009 will be on Tuesday June 9, 2009
Go to http://www.iua.org.uk/join to get on the mailing list.




Reply With Quote
  #6  
Old   
nikosv
 
Posts: n/a

Default Re: Auto generated sequences - 02-05-2009 , 03:08 AM



On 3 Φεβ, 13:53, Roy Hann <specia... (AT) processed (DOT) almost.meat> wrote:
Quote:
nikosv wrote:
can someone shed more light into the new feature of auto generated
sequences?
are they just for convenience or do they eliminate the concurrency
issues associated with
unique key generation? because I see that they take logical locks

I wouldn't say they eliminate concurrency issues. *They certainly reduce
the risk of lock contention (and hence queueing) on the last-value
table. *For the knowledgeable programmer the benefit is just the
convenience of not having to write the small amount of code needed
to generate values. *The big winners are the naive programmers who
didn't even know there was a problem. *

But contention on the state table is only part of the problem.
Using monotonic physical key values to insert into a B-tree or an ISAM
table is still a massive concurrency problem in a busy system. *You can
relieve it somewhat by using row-level locking, but there's limits to
how far even row-level locking will scale, and there is no guarantee you
will get row-level locking even if you ask for it.

Ingres Database 9.3 includes (or soon will include) "unordered"
sequences, which supply unique values in non-sequential order.
Using these values as physical keys will effectively randomize insertion
into B-trees and ISAM tables, eliminating concurrency problems.

is it possible to introduce gaps between the sequence by means of
server failure, aging out of the shared pool in case of caching, or
programatically?

You certainly still run the risk of gaps. *But gapless sequences are a
perforance killer no matter how you generate the values. *You can't
allocate the next value until the previous value has been used AND
committed. *That makes your system essentially single-user. *It will not
scale at all. *The preferred solution (preferred by the programmer if
not the business) is auditable numbers. *You generate a block of
numbers and store their current disposition in a table in the database;
you dole them out as a separate operation as needed. You don't
insist on using them up in strict order, but you do require them to be
traceable, so that you can supply information like: the numbers 9, 10,
11, and 12 have been generated, and the numbers 9,10, and 12 have been
used (and committed), but 11 is still in the pool waiting to be used,
and will be used before we generate another block of numbers.

The one time I have had to deal with genuinely in-order gapless
numbers in real life was when I was outputting onto pre-printed
certificates that already had a serial number, and I had to know the
number of each certificate I was printing. But in that case the
numbers were really a natural key. *(The same problem arises with
pre-printed cheques.) But happily those are both single-user jobs so no
problem. Other than that, the need for gapless numbering is rare, I
find. If your users are trying to tell you different, I'd ask them
some hard questions before meekly giving in to their request.

--
Roy

UK Ingres User Association Conference 2009 will be on Tuesday June 9, 2009
Go tohttp://www.iua.org.uk/jointo get on the mailing list.
great in-depth explanations, clarifies it


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.