Skip to content

Materialized views are stored under first byte 0x07.

0x07 ‖ view_id u32 BE ‖ …
  • The key 0x07 ‖ view_id ‖ 0x00 is the cursor key. While a view is being built its value is the table key where the next backfill chunk starts; it is deleted when the build ends.
  • A group entry is 0x07 ‖ view_id ‖ group key ‖ kind u8, where the group key is the order-preserving encoding of the group-by values. Kind 0x00 is the folded base entry. Kind 0x01 is a delta entry and is followed by a 16-byte unique tag (8-byte boot tag and 8-byte transaction counter, big-endian).
  • The value of a base or delta entry is the aggregate slots, each a zig-zag varint of an i128, with no length prefix. A reader sums the base and all delta entries of one group; deltas are folded into the base once a group has about 8 entries.
  • Group keys start with an encoding tag of at least 0x01, so they sort after the cursor key.

The view id, name and defining SQL are stored in the table definition, see Ext V: materialized views.