"Brian Johnson" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > > "Brian Johnson" <[EMAIL PROTECTED]> wrote: > > > Why does a INTEGER PRIMARY KEY field autoincrement when inserting a NULL > > > into > > > that field as per http://www.sqlite.org/faq.html#q1 and a field defined > > > as int > > > primary key not work the same way? > > > > Because you might really want to insert a NULL into some > > other INTEGER field. But inserting a NULL into an INTEGER PRIMARY KEY > > makes not sense. Also, we can find the largest existing > > INTEGER PRIMARY KEY in logorithmic time - or constant time > > if the caching mechanism works. Finding the largest > > value of an regular INTEGER column is linear time and > > is thus *much* slower. > > I don't understand this explanation. Are you saying that: > 1. a field defined as int primary key is supposed to be different than a field > defined as INTEGER PRIMARY KEY? > 2. finding the largest value of an INTEGER PRIMARY KEY field is faster than > finding the largest value in a regular INTEGER field >
2. Finding the largest current value of an INTEGER PRIMARY KEY field (which is something you have to do for autoincrement) is asymptotically faster than doing so for a plain INTEGER field. -- D. Richard Hipp <[EMAIL PROTECTED]>

