Kervin L. Pierre wrote:

Lloyd Dupont wrote:

But to my disbelief there is (apparently) no way to get the size of a blob (other than loading it :-()


I'd like to be corrected if I am wrong, but I
don't think there is anyway to do this in
SQLite, besides simply storing the size of the
blob with the blob when you write it into the
database.  SQLite stores BLOBS 'in-row' so it
has to read the entire BLOB into memory before
it figures out the size.  I believe even the
'column_bytes' function 'suffers' from this.
Tried to find out the feasibility of 'out-of-row'
BLOB in SQLite once, but I don't think there was
much interest in that.

Regards,
Kervin



Kervin,

You can do the out-of-row blob storage yourself by simply storing the blob data in a separate table and joining it to one that stores info about the blobs, such as their size. You can then get the size first without reading the blob into memory, then use a join to get the blob data.

create table blob_info (id integer primary key, size integer);
create table blob_data (id integer primary key references blob_info(id), data blob);

HTH
Dennis Cote

Reply via email to