Hello sqlite list,

Given the following table with large page size (32 KB):

----------------------------
CREATE TABLE table
(
  column_0 INTEGER PRIMARY KEY,
  column_1 INTEGER,
  column_2 REAL,
  ...
  column_n INTEGER,
  column_blob BLOB
);
----------------------------

With 'column_1' to 'column_n' being BLOB nor TEXT columns.

What would be the maximal allowed size of the blob in order to make a
single record fit onto a single sqlite page? I want to avoid overflow
pages as I can make the BLOBs any size I want (they are part of a
continuous data stream).

I took a look at the sqlite file format documentation and I have
deducted the following formula:

----------------------------
MAX_BLOB_SIZE = 

SQLITE_PAGE_SIZE [32K] - DATABASE_HEADER_BYTE_OFFSET_20 [0] - 35

- RECORD_SIZE [VARINT]

- KEY VALUE [VARINT]

- RECORD_HEADER_SIZE [VARINT]

- N * (HEADER_TYPE [SINGLE_BYTE_VARINT] + RECORD_DATA [VARINT])

- BLOB_HEADER_TYPE [VARINT]
----------------------------

with

[VARINT] = 9
[SINGLE_BYTE_VARINT] = 1


Any comments or improvements would be appreciated.

Thanks in advance,

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

Reply via email to