Martin Pfeifle wrote:

Hi,
Assume I have a table containing an integer primary key. As far as I know, this 
value is identical to the ROWID, right?
How does SQLite organize the data within the file?
Does it try to organize the data on the pages according to the primary key 
(=ROWID) or according to the insertion order of the records?
Can anyone explain that to me?
Best Martin

Martin,

An integer primary key is the rowid which is the key for the b-tree used to store the table. The way the b-tree is constructed is explained in the comment at the beginning of the source file btree.c which you can view here http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/btree.c&v=1.324. Basically it is a tree of blocks with similar rowid values and pointers to other blocks with larger and smaller rowid values.

HTH
Dennis Cote

Reply via email to