Overview

Backend

Document model

A row has an id, application attributes, and optionally a vector. Supply these fields in write requests. Use the store matrix for supported attribute and write shapes.

Reserved attributes

The _hevlayer_* prefix belongs to the gateway. Do not set these attributes in client writes. Select your backend to see which attributes Layer manages.

AttributeTypePurpose
_hevlayer_upserted_atinteger (epoch ms)Server-stamped on row-producing writes through Layer. Records when the gateway received the write.
_hevlayer_shardintegerHash bucket stamped on every row Layer writes (xxh64(id) % shard_count). The count is the namespace’s shard marker, or LAYER_SHARD_COUNT (default 16) before one exists. Not related to Turbopuffer’s own sharding. Lets the gateway scatter/gather a query across the shards of one namespace.

Initialize an existing namespace with layer init <namespace> --shards N to backfill rows written before Layer. Scatter/gather starts after layer.shard_lag_rows reaches zero.

Layer keeps the same no-SQL document model over Postgres. Your schema and document attributes are mapped onto internal Postgres rows and indexes so the database can filter and rank them efficiently. Those rows are an implementation detail: there is no database table or SQL interface for an application to use.

All reads and writes go through Layer’s Turbopuffer-style JSON APIs, including the document fields, filter expressions, and vector queries. You do not need to know how the underlying rows are laid out, and you cannot interact with them directly. SQL transactions and indexes provide write visibility and query execution behind that API, so Layer does not need _hevlayer_upserted_at visibility stamps or _hevlayer_shard hash buckets for this backend.

Row and column upserts insert a new row or replace the row with the same id. If your application needs a per-row modification time, supply an attribute such as updated_at; transaction visibility does not add a timestamp to the row.

esc