On Sep 3, 2009, at 8:25 PM, Mark Spiegel wrote:

> D. Richard Hipp wrote:
>> You are both right and both wrong.  There are two different integer
>> representations used in SQLite.
>>
>> (1) "varint" or variable length integer is an encoding of 64-bit
>> signed integers into between 1 and 9 bytes. ...
>> (2) When you store an integer into a column (a column other than the
>> rowid) it is stored as a 0-, 1-, 2-, 3-, 4-, 6-, or 8-byte signed
>> integer. ...
> That makes sense.  Thank you for clarifying.  One further question.   
> It
> seems when we profile, that a lot of time is spent encoding and  
> decoding
> varints.  Are there really that many multi-byte varints in use in the
> system?


Most varints are "type varints" and type varints are almost always a  
single byte (the only exceptions being for large blobs or strings).   
Varints are also used to store the total number of bytes in a row  
(also usually one byte).  Most varints are a single byte.

We, too, have profiled, and we agree that a lot of time is spent  
decoding varints.  As you have already observed, the common case of a  
single-byte varint is usually handled by by a macro and so never calls  
the sqlite3GetVarint() decoder function.  And sqlite3GetVarint() is  
very carefully coded to be fast even when it is called.  The varint  
decoder is one of the more carefully scrutinized parts of SQLite.

I'm scanning through some profiling output now and I'm seeing that  
some varints are almost always a single byte (only 60 multibyte  
varints out of 474350, in one example) while others are multibyte  
about half the time.  I'm not seeing any cases where more then half  
the varints are multibyte.

D. Richard Hipp
d...@hwaci.com



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to