Skip to main content

Segment Format (.lsg)

LynxDB stores immutable columnar segments in the .lsg format. The current format-major is v1 and every v1 file starts with the LSG1 magic.

Layout

RegionMagicPurpose
HeaderLSG124-byte file header with major version and capability summaries
Column chunksnoneEncoded column data referenced from the footer
Bloom regionLSBLPer-row-group, per-column bloom filters
Inverted indexLSIXFST term dictionary plus roaring bitmap postings
Primary indexLSPKOptional sparse sort-key index for materialized-view segments
FooterLSGEEvent count, row-group metadata, catalog, region offsets

The footer trailer is 12 bytes: footer payload length, capability summary, and CRC32-IEEE over the footer payload plus trailer fields up to the CRC.

Versioning

The data-directory root contains a FORMAT marker:

LSGFMT v1

On boot, LynxDB validates the marker before loading segments. Unknown majors, unknown required capability bits, invalid magic bytes, and marker mismatches refuse startup. Physical corruption such as footer checksum failure remains a per-file warning so the rest of the directory can still load.

Capabilities

Format-major v1 defines one required capability bit:

BitNameMeaning
0ColumnZSTDAt least one column chunk uses ZSTD layer-2 compression

See the canonical storage-format document in docs/storage-format.md for the compatibility table, capability registry, and runbooks.