Skip to content
Advertisement

Is it possible to optimize table if I know all blobs will have the same size?

I know for sure that all blob entries on the table will have the same size, but I only know the size at runtime and would rather avoid byte1, byte2, byte3, etc
I assume this was asked a billion times already, but I can’t seem to find the right keywords to find such a question, neither here or google

Advertisement

Answer

If you mean to optimise storage of the data itself, then no, other than to perhaps save a compressed version of the data.

SQLite, with the exception of the rowid or an alias of the rowid column (for rowid tables as opposed to the rarer used WITHOUT ROWID tables), optimises the storage of the data (e.g. for integers the value will be stored 1, 2, 3, 4, 6, or 8 bytes rather than always 8 bytes). Blobs are stored as they are as per

BLOB. The value is a blob of data, stored exactly as it was input. Datatypes In SQLite Version 3 – 2. Storage Classes and Datatypes

However, if you mean optimise, such as in searching, then BLOBS are inefficient from a search ascpect.

If you mean File/access then BLOBS can be faster than the file system as per :-

SQLite reads and writes small blobs (for example, thumbnail images) 35% fasterĀ¹ than the same blobs can be read from or written to individual files on disk using fread() or fwrite(). 35% Faster Than The Filesystem.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement