On 1 May 2015, at 6:49am, Pol-Online <info at pol-online.net> wrote:

> I?m curious: how much work are we talking about here? If I have 99 INTEGER 
> fields followed by a BLOB one, to access the BLOB field, does SQLite need to 
> compute the size of each previous INTEGER field first?

Given the way that SQLite uses different sized fields for different integers, 
yes.  Also, given that SQLite columns have affinity and not type, it has to 
calculate these sizes separately for each row retrieved.  It can't use the 
table definition and calculate one set of positions for all rows.

Fortunately, the lengths of all columns in a row can be calculated by looking 
at the serial types of all the columns, which are stored in a block at the 
beginning of the row data.  So the format is not

Type of column 1, data 1, type of column 2, data 2, type of column 3, data 3 ...

it is

Type of column 1, type of column 2, type of column 3 ..., data 1, data 2, data 
3 ...

so SQLite doesn't have to read through variable-sized data to work out where 
later columns are.

More info in places around section 2.1 of

<http://www.sqlite.org/fileformat.html>

Simon.

Reply via email to