On Wed, 19 Apr 2006, Joe Wilson wrote: >--- [EMAIL PROTECTED] wrote: >> Joe Wilson <[EMAIL PROTECTED]> wrote: >> > >> > If you read the blob all in at once, true. >> > But doesn't sqlite3BtreeData() allows you to read a partial chunk of >> > data from the blob at an arbitrary offset? This could be advantageous >> > if you are dealing with multi-megabyte blobs and do not require/want >> > the entire blob in memory at once. >> > >> >> sqlite3BtreeData() actually reads a prefix of the data. >> Because of the way large blobs are stored (as a linked list >> of disk pages) you have to start reading at the beginning >> and read everything up to the point of interest. > >Random access for blobs would be ideal, but even a sequential block >fetching mechanism for blobs would be a useful SQLite API addition.
You could simply partition the blob yourself, and use a compound key to access parts of a BLOB at random: CREATE TABLE blocks ( id integer, offset integer, block blob, primary key (id,offset) ); Assuming you store, say, 16K in each block, then access to any one 16k block then becomes a single index lookup and 17 page reads. Much more efficient than storing the whole BLOB in one. Christian -- /"\ \ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \