Limits
What fennecdb does not do, the ceilings in its code, and the behaviour worth knowing before it surprises you.
Out of scope
Before you choose it, at a glance:
- FennecQL, not SQL.
select a from t,insert into t (a) values (1),update t set a = 1,in (…),between,likeand ajoinon an indexed key work (From SQL); a join of any other condition does not.lookupcovers related rows (below). - One writer per file. Readers run beside it, and a
/batchholds the writer while it runs. Scale out with a file per tenant (Sharding design). - Indexes live in memory. The data stays in the mapped file; the indexes are restored or rebuilt on open (Memory and scale).
- Typed fields, and
jsonwhere a shape is not fixed. Ajsonfield holds objects, lists and scalars, and a path (meta.lang) reads into it (Objects and paths). - TLS on the ports clients reach, and on the links between
servers.
--tls-certmakes the server and the router serve HTTPS; what they dial themselves takes anhttps://URL, held to Mozilla's roots or to--tls-ca's CAs, with no client certificates (Server).
Deliberately not done: JOIN, SQL as the query language, several writers to
one file, multi-writer replication, a field's type changed in place (it
would rewrite every document under the write lock). A row's
expiry is @ttl, a filter by
another collection's rows is
in (get …), a unique field is
@unique, a field is
added, dropped or renamed with
alter collection,
and nested objects are a json
field.
Relations, one-way replication and type gaps
These are consequences of the design, hard-coded ceilings, and behaviours it is cheaper to read about than to discover. The few that are planned say so.
Relations are lookup
rather than JOIN: it attaches a collection's matching documents to the row they
belong to, which is one bucket probe per parent and a limit that
counts children per parent. It chains up to 8 levels, and
required lets the children decide which parents appear. What it
still does not give is a predicate spanning both sides —
products.price > reviews.cost cannot be written, because the
positional scoping that keeps qualified names out of the language leaves a
predicate no way to say it reads two collections. That stays a second
query.
Replication exists in one direction only: the server is
authoritative and clients read it. A replica's writes wait in a queue kept in
its own file (_sync_queue), in the browser and on a phone, and
reach the server one at a time, each once under its
Idempotency-Key; the server answers each, and a write it refuses
is put back (Sync,
mobile). Multi-writer merging and CRDTs are out
of scope — that is what fits the single-writer model, and the other would be
a different database.
There are deliberate gaps in the type system too:
- No decimal.
floatis binary floating point and unfit for money. The answer is anintin cents. - No UUID type.
text @hashis functionally enough. - Objects only in a
jsonfield. A typed field still refuses one, and a list of a type holds that type alone. Ajsonfield holds any value JSON does; a path filters, orders and is indexed (@hash,@unique,@sorted), but an aggregate andgroupread a field, and text, vector and sparse indexes stay on typed fields.
Fixed limits
Ceilings baked into the code. Exceeding any of the first seven makes the query error, because a silently cut result is a wrong answer believed right; so does going past the nesting depths and the path length.
| Limit | Value | Note |
|---|---|---|
near, match, fuse ranking (limit + offset) | 10 000 rows | a query error when exceeded, by a number written or a parameter's (limit $2); without limit, the default top-k applies. A match beside order, count or an aggregate ranks nothing and has no ceiling of its own |
words one word of a match ... fuzzy or prefix reaches | 10 000 | the word itself among them; a query error naming the word past it, never some of them taken — a search box sends its second letter, or its first over a smaller vocabulary (FiQA's 80 426 words: s reaches 7 020) |
edits fuzzy N takes | 2 | and only what a word's length allows: none under 5 characters, one up to 8; past 2, a parse or query error |
rerank candidates, fuse candidates a side | 10 000 | from 1; a parse error naming the range when exceeded; never fewer than limit + offset |
fuse k | 1 000 000 | from 0; the weights are f32, and far past it two neighbouring ranks weigh the same, so a parse error naming the range, never clamped |
near … ef, @hnsw's ef_search and ef_construction, a snippet's words | 4 294 967 295 | 232 − 1, from 1 (ef_construction from 4, pgvector's floor, as SQL's with (ef_construction = 4)); refused naming the range past either end, never clamped nor cut to 32 bits in the browser module |
| expression depth | 512 levels | parentheses and and/or chains count |
lookup chain depth | 8 levels | a query error when exceeded; the parser, the check and the engine all recurse per level |
fields of a lookup key | 8 | as many as an index over several fields has parts, whose first ones they must be; refused past it, naming the index to declare |
in (get …) values | 100 000 | distinct values, each counted once however many rows hold it; a query error naming the bound when the inner get finds more; never a set cut short |
a policy rule's in (get …) values | 1 000 | a list claim's bound, not a statement's 100 000: the list is made before each statement its token sends. Each value counts once however many rows hold it, and an inner get with a limit, an offset or a computed column, or selecting a nocase or json field, is read on past its first rows as far as a statement's own would be (100 000 rows; with a group, 100 000 groups, however many rows they fold); past either a query error (400) naming the bound and the rule, never a list cut short. An inner get that ranks its rows (match with no order or aggregate, near, fuse, rerank) stops the server at startup: a ranking is a page, not a set |
in $1 values | 100 000 | the list one parameter holds; a query error naming the bound past it, or naming the form where the parameter holds no list, before a row is read — over an empty collection too — never a list cut short |
in (get …) nesting | 4 levels | a query error when exceeded; each level runs a query before the one around it |
a require's reason (else '…') | 200 bytes | of UTF-8; a parse error naming the length found when exceeded, and for an empty reason, a backtick in one or a parameter; never a reason cut |
values of one facet | 10 000 | a query error when a facet without top finds more, and for top past it, written or a parameter's; never a list cut where it stopped |
ranges of one facet ... ranges | 10 000 | a query error past 10 001 bounds; every range answers |
json value nesting | 64 levels | objects and lists inside one another; a write or a JSON text deeper is refused, never cut. Every value read back is held to the same 64 — a file's, a primary's record a replica applies, a page's image — and one deeper is refused as damage (a value nests more than 64 levels deep) where it is read, never decoded until the stack runs out |
| list type nesting | 64 levels | [[int]] is two; a geo point counts one, being [lon, lat]. A type deeper is refused where it is declared (a list type nests at most 64 levels), and so is a list of json at any depth — [[json]] as [json]: a json field holds a list. A file whose schema declares a type deeper is refused at the open, as damage |
| places a collection holds over its life | 4 096 | its fields and the ones dropped from it, whose places its documents keep — compact makes a dropped field's values nulls and keeps the place, a byte in each document a field after it is in. An alter collection ... add field past it is refused, and a create collection declaring more fields; the way out is to make the collection again: create another and copy the rows into it. A file holding more, an earlier version's, opens as it is, and its collection takes a rename or a drop |
| path length | 64 keys | past its field (meta.a.b is two); a query error, since no value nests deeper |
| fields of an index over several fields | 8 | refused past it, and under 2: one field's index is its own @sorted or @unique |
spans the in lists over an index's parts make | 256 | the elements of each, multiplied; past it the list is tested row by row, never cut |
session stack (fennec-server) | 8 MiB | virtual; the deepest expression wants ~750 KiB in release, ~5 MiB in debug |
| segment size | 8 MiB | sealed when full, a new one is opened |
| document payload, segment offset | 4 294 967 295 bytes | 232 − 1, the location record's length being a u32: a write past it is refused before it changes anything (a document is at most 4294967295 bytes encoded), never cut, and a file or a primary's record holding one is refused as damage — a file an earlier version wrote with such a document does not open. The browser module, whose values stop at 2 GiB, never reaches it |
| vector index node count | 4 294 967 295 | 232 − 1, the node id a u32; a node written over or deleted stays a tombstone, and counts, until its graph is rebuilt: beside the queries once the tombstones outnumber the live nodes, 10 000 of them at least, or by a compact, so a graph whose rows are written over holds at most about twice their nodes. A write whose vector would take one more node is refused before it changes anything, naming the field (a vector index holds at most 4294967295 nodes), never wrapped, and so is a create index or an open of a file holding more vectors in the field than its nodes hold — rows holding one vector share its node. A write put back gives each row the node it had, its links with it, so a rollback at the bound places none; the nodes the write placed stay tombstones until the graph is rebuilt. A compact whose writes meanwhile would take its rebuilt graph past the bound keeps the graph it has and says so in its log line. A replica takes every write its primary took, its graph made again without its own tombstones where they crowd it; memory runs out first in practice |
@hnsw's m | 2–32 767 | level 0 keeps 2m links, a u16 counter; refused naming the range past either end, never clamped. A file whose schema holds a field past it, or past the dimension below — a damaged or crafted file's, or one an earlier version made — is refused as damage where it is opened and where a replica applies it, naming the field and the range |
| bulk insert batch | 64–512 vectors | graph/16, clamped to this range |
| parallel build threshold | 1024 vectors | below it, the serial path |
gap in an externally given id | 4096 | a larger jump falls into a sparse map rather than a dense array |
int | i64 | -9223372036854775808 to 9223372036854775807; a number past it — 1e300, a JSON integer past 64 bits, a set's float result — is a type error naming the field, never clamped to the nearest int. A float goes in where it is whole and short of 263 either side, so -9223372036854775808 is taken written as an integer, not as a float (JavaScript writes -(2 ** 63) as -9223372036854776000). An [int]'s elements are held to it the same way, each read as written and one past it refused naming the field and the element, counted from 0; a row an earlier build wrote keeps the f32s it stored, 16777216 for 16777217, until written again |
float | f64 | ±1.7976931348623157×10308, and 0 or at least 5×10-324 either side of it; a number is read as the nearest float, and one past either end — 1e400, 1e-400 — is refused naming it, where it was and the range, in a JSON body or parameter, a FennecQL literal, the query string and an import, never read as an infinity (which JSON writes as null) or as 0. A NaN or an infinity a field holds already — an import of PostgreSQL's, a value put through the native APIs, one an earlier version read from 1e400 — is kept, written as null, and a named statement stored before reads its text as it did |
timestamp | 1 ms, i64 | ±2.9×108 years; microseconds truncated, always UTC |
bucket by a named zone | from 2000 | IANA's rules of the build's tzdata (2026c); a time before 2000 is a query error, never answered by rules the build does not hold; an offset written out ('+03:00') answers any time |
vector<N> component | ±3.4×1038 | an f32, at most 3.4028235×1038 either side of 0; a component past it — 1e39, which an f32 rounds to its infinity — and a NaN or an infinity sent as f32s are refused naming the field and the element, counted from 0, in every write and in near's and rerank's query vector, never stored to come back as null; one at or under half the smallest subnormal, 7×10-46, is 0, as pgvector reads it. A vector an earlier version stored with one is kept and read as before |
vector<N, f16> | ±65 504 | ~3 decimal digits; a component of 65 520 or more either side of 0, which rounds to the f16's infinity, is refused naming the field and the element, never stored to come back as null; one at or under about 3×10-8, half its smallest subnormal, is 0 |
geo point | ±180°, ±90° | two f64s kept as written; past either range a write is refused, never wrapped |
vector<N> and sparse<N> dimension | 109 | pgvector's for sparsevec, and a vector<N>'s f32s still fit a document's 4 GiB; refused past it, never cut, a list's too — [vector<N>], SQL's vector(n)[] — naming the field and the range, as a file's schema is read back; a sparse vector's weights are f32, finite, and a zero is dropped |
| change ring | 4096 entries | --changes; how far behind a subscriber may fall, 24 bytes each |
| concurrent subscriptions | 64 | --http-max-streams, a database's; each is a connection and a thread, counted apart from --max-connections once it streams, unless the ceiling is 0; on a tenant node, each tenant's own, and one of the --max-connections every tenant shares |
a tenant's file (--dir) | none unless set | --tenant-max-bytes, a tenant's own bytes; a write that would take the file past it is refused (507) before it lands; deletes, drops and compact run |
| a tenant's rows | none unless set | --tenant-max-rows, its rows; its collections together, the server's own (_-named) left out; 507 |
| a tenant's streams | a quarter of --max-connections unless set | --tenant-max-streams, its streams: subscriptions, /_changes waits and Fennec-After waits together; 429 |
| a tenant's held writes | a quarter of --max-connections unless set | --tenant-max-held, its held: writes held until they can write (Fennec-Wait); 429 |
| a tenant's requests in flight | none unless set | --tenant-max-requests, its requests; 429 |
| a tenant's rows written a second | none unless set | --tenant-writes-per-sec, its writes; charged the rows each write lands, a write of none costing none; 429 while in debt, retry_after_ms to the millisecond |
| a tenant's bytes written a second | none unless set | --tenant-write-bytes-per-sec, its write_bytes; charged as each write lands, 429 while in debt |
| rows an MCP tool answers | 100 | --mcp-max-rows; past it the call is refused (413) with what to narrow, never cut (Agents and MCP) |
| bytes an MCP tool answers | 64K | --mcp-max-bytes, the answer's JSON; refused past it (413) |
| MCP tool calls a second | 20 | --mcp-calls-per-sec, a scoped token's issuer and subject or an address, in each database; 429, with when to call again |
| rows a named statement's call examines | 100 000 | --call-max-rows; counted wherever its statements read rows: a scan, an index, an ordered walk, near, match and a lookup's children; past it the call is put back and refused (400) naming the bound, never answered from the rows it reached |
| named statement calls a second | 100 | --call-rate, a scoped token's subject and issuer in each tenant, the server's token not held; 0 for none; 429, with when to call again (Calling a named statement) |
| requests a second from one scoped caller | 1 000 | --request-rate, a scoped token's subject and issuer in each database or tenant, every route counted — reads, writes, /batch, calls, a subscription as it opens, MCP; the server's token and a server asking no token not held; 0 for none; 429 before anything of the request runs, with Retry-After and retry_after_ms (Requests a second) |
| values of a list claim a named statement's call reads | 1 000 | as a token's list claim a policy reads; past it the call is refused (403), never run with the list cut short |
Memory and scale
The documents stay in the file and the indexes are held in memory, so a
server's memory follows its indexes, not its data. The largest of them is
usually the vectors. The file is mapped on Linux, macOS and Windows; on
Windows its volume must be NTFS or ReFS and not a network share, or it is
read into memory and the documents count too, as with
--no-mmap.
- A 1 GB file of 2.3 million rows with two indexes holds 188 MB mapped.
- One million 768-dim vectors take about 3 GB, 1.5 GB as
f16, 772 MB as int8 codes and 105 MB as bit codes. - Set
--max-memoryto a third of the container's memory.
What a file costs to hold, measured
The documents stay in the file and the indexes are in memory. The
file is mapped (The file is
mapped), so a document is read from the pages the operating system holds
and can drop; what the process holds is the offset index, the hash, ordered
and text indexes, the graph, and the documents written since the open until
they amount to 16 MB and are handed over to the file — a large
/batch's spilled into it as it goes.
- What a file costs to hold. A 1 GB file of 2.3 million rows with
a hash and an ordered index: 188 MB mapped, against 1 095 MB read into
memory (
--no-mmap). A 10 GB file of 23 million rows opens on an 8 GB machine, which reading it cannot. compactpeaks at the indexes, not the data. On that 1 GB file: 236 MB and 2.08 s mapped, 2 012 MB and 1.52 s read — the mapped one writes the live records into the new file and points at it, copying nothing and rebuilding no index but a graph holding tombstones. It takes longer and holds a ninth of the memory. Acheckpointis the same path with the dead records kept.- Open cost is proportional to data size, not constant. The graph is restored, reading every vector, and the offset index is built: mapped, from the index of its records the last checkpoint wrote, and walking the records written since; read into memory, walking them all. The hash, text, ordered and sparse indexes are built from the documents by the first query that reads each. 100 000 × 128 with the graph in the file opens in about 9 ms, which a single vector query makes up against SQLite's 30 ms scan.
The vector arena is the largest item: one million 768-dimension vectors is
about 3 GB, or 1.5 GB with f16, 772 MB as int8 codes and 105 MB
as bit codes (quant=)
— the documents keep their vectors either way. In the browser nothing is
mapped: there the whole file is in memory, inside WASM32's 4 GB address
space, which is the real ceiling there.
Database::memory_bytes() sums the segment bytes, the offset
indexes, the vector arenas, the graph links, and the text, sparse, hash and
ordered indexes, and --max-memory uses it before every write
that grows the data. Each index keeps its count as it changes, so asking
costs nothing next to the write: summed over every term instead, a text
index of 200 000 documents took 0.42 ms a call. It is not RSS: allocator
slack, HNSW build buffers, upper-level neighbour allocations (~3% of level
0) and the transient peaks all sit outside it. On the 1 GB file above,
opened mapped, it counts 197 MB where the heap holds 188, 34 of them the
hash index.
| measured footprint | peak RSS | ratio | |
|---|---|---|---|
| 100 000 × 128 | 128.2 MB | 172.9 MB | 74% |
| 200 000 × 4 | 57.6 MB | 97.2 MB | 59% |
So the ceiling is an early warning, not a guarantee. A third of the
container memory is a sensible start: it covers both this 60–75% ratio and
compact's 3× peak.
Past one machine the data is split by tenant, not by row: each tenant is a file of its own, nodes hold many, and a router forwards each request to the right one (Sharding design). The bound moves from "the database fits one machine" to "each tenant does" — a single tenant larger than a node is still out of reach. A single file has read replicas, but a tenant node does not yet, so a node that is down takes its tenants with it.
Index build, open and maintenance
Indexes are rebuilt or restored when a file opens, and the vector graph is saved to the file at checkpoints, never on each write. A crash or a skipped checkpoint costs time at the next open, never data.
- A server answers while it relinks vectors written since the last checkpoint, and keeps its graphs in the file as they change.
- A server builds an index or compacts beside the database, so reads and writes wait milliseconds, not the whole build.
- Deleted or changed vectors stay in the graph until
compact, slowingneara little.
Graphs, compaction, batches, ordered indexes and buffered writes
- The graph is derived data and is written only during
snapshot,compactandcheckpoint— never on the write path. Without it in the file it is rebuilt on open: 0.90 s every open at 20 000 × 32, against 0.01 s with it. - Who writes a checkpoint: the
fennecshell when leaving an interactive or piped session, andfennec-serveron the shutdown signal — both only if a vector index exists. A one-shotfennec file.fennec -c '...'does not. Neither doeskill -9or a cgroup OOM. The next open then restores the graph the last checkpoint wrote and applies the writes since it, so what is lost is time, not data: with 1 000 writes after the checkpoint, 0.07 s at 100 000 × 128 and 0.29 s at 100 000 × 768. The time grows with the writes since the checkpoint, and a server does not wait for it: their vectors go in unlinked,nearmeasures each of them, and a thread beside the queries links them. At 100 000 × 768 never checkpointed,fennec-serveranswered its firstnear1.23 s after it started, against 67.7 s when the open linked them first, which now takes 18 s;neartakes the exact scan's 10.5 ms until the 19 s of linking are done, and 0.31 ms after. A server also keeps its graphs in the file as they change, so what waits is what came after the last of them: at 100 000 × 768 at most 10 000 vectors, linked in 2.6 s withnearat 1.56 ms meanwhile, where every vector took 19.1 s in the same run. compactrebuilds a graph only when it holds tombstones. The dead records go and the other indexes stand; a vector graph with a deleted or rewritten document's node in it is built again from the live vectors, which is what acreate indexof it costs — 50 s at 100 000 × 768. A graph whose tombstones outnumber its live nodes is rebuilt by every compact, whichever collection it names.- A server builds an index or compacts beside the database. A
create indexorcompactsent on its own tofennec-serverorPOST /querytakes under the read lock only the collection as it stands, shared rather than copied, reads its documents and builds with no lock held, catches up with the writes made meanwhile beside the queries, and takes the write lock only for the last of them and to put the result in place. At 100 000 × 128, where either takes about 20 s, reads waited at most 21 ms through an HNSW build and 30 ms through a compact — the compact's includes rewriting the file — against the full 20 s under the write lock, and writes went on at the same pace. Over a mapped file the compact copies no record: the graphs holding tombstones are rebuilt beside the database, the live records are written into a side file with no lock held, and the write lock is taken only to add the documents written meanwhile and rename it into place. Over 1.8 million × 128, a 1.1 GB file, writes waited at most 24 ms, where the rewrite under the lock held them 1.22 s, for 67 MB more heap at the peak. The records those documents superseded stay in the new file as dead ones until the next compact. Through 0.2.0 a compact read the vectors of a graph it rebuilt, andcreate indexits field, under the read lock, which past the page cache held every write — and every read behind a waiting write — for seconds: 0.9 to 2.5 s in a container of 512 MB over a 2 GB file with 20 000 vectors, where now they are read with no lock held, no hold of the compact's own passes 0.25 s and a read waited 0.24 to 0.43 s at most. One in a batch, or run by the shell or an embedding program, still holds the write lock throughout. A schema change to the same collection while it builds — another index, a drop — fails it with a request to run it again, since what was built no longer fits, and so does a second compact while one writes its file; a compact of every collection places no graph when one of them changed. The vectors written while a graph is built are linked into it in rounds beside the queries, and the write lock links at most about 0.1 s of them at anymandef_construction, those of the last round — 128 at 768 dimensions, 66 at 1 536, 33 at 3 072 at the defaults, as many fewer as a widermoref_constructionmakes each link cost more: 32 at 768 dimensions withm = 32, ef_construction = 400, 10 with 48 and 800. Where more were written than that, faster than the rounds could link them, acreate indexof the graph is refused, saying so, and a compact keeps the graph as it stands until the next, its log line naming it. Settings under which one link costs more than the whole bound — at 768 dimensionsmtimesef_constructionpast 409 600 — link none under the lock: any vector written during the last round does so. The documents written during a compact's last round and the handover after it are copied under the write lock with no such bound: beside 1 000-rowPOSTs at 10 000 to 30 000 rows a second that held every write 6.6 to 29 ms, but as fast as three CPUs wrote them 3.8 to 6.4 s, and the copies waiting for the handover took 1.5 to 1.7 GB of memory (Compaction). It cannot be cancelled once begun. - A file compacts itself once half of it is dead. The server
(
--auto-compact, Compaction) and the native library (FENNEC_OPEN_NO_AUTO_COMPACTturns it off) look every 5 s and compact beside the queries once the dead records are half the file and 64 MB, so a file under updates stays under about twice its data, and its peak while the compact writes is the old file and the new one together. A file that reaches three quarters of the memory the system has for its pages is compacted sooner, once a third of what the compact writes is dead, so its reads stay in memory: up to four bytes written a byte updated against two. Over a million 1 KB records updated at 150 000 a second, each compact held the write lock 6 to 13 ms. Such a compact stops, writing nothing, while it rebuilds the vector graphs before it writes the file, once the database is closed, its tenant deleted, moved or made to follow, or the server stops; one writing the file finishes first. An embedding program callscompact_when_due_untilfrom a thread of its own, with a closure that says when it closes the database, or starts aCompactor, which stops as it is dropped (embedding); the browser module has no thread to run one, and drops the dead records from each image it persists. - A delete is a tombstone and the graph node stays in memory, its
vector and links in the graph's record in the file, until the graph is
rebuilt. Changing a document's vector also marks the old node deleted
and adds a new one, so in collections whose vectors change the graph
grows — and the tombstones take places in the beam
nearwalks — until then. The server and the native library rebuild a graph beside the queries once its tombstones outnumber its live nodes and number 10 000, as a compact rebuilds it but writing no file, and acompactrebuilds it whichever collection it names; the browser module, with no thread to run one, rebuilds it at itscompact, and an embedding program callsDatabase::rebuild_wornfrom a thread of its own or starts aCompactor. 20 000 × 16 updated 500 000 times held 520 000 nodes, 122 MB of heap and a 64.5 MB graph record never rebuilt, and so rebuilt 41 000 nodes, 16 MB and a 4.1 MB record at the most, each rebuild 0.44 s beside the writes with the write lock held 1.9 ms at most. An update of the other fields leaves the node where it is: 0.006 ms for a title at 20 000 × 768, where taking the vector out and back in cost 1.89 ms and a tombstone. A page tombstones cut short is walked again with the beam wider by their number, or searched exactly where that walk would cost more than reading every vector, so the answer is whole and only slower until the graph is rebuilt. - Documents inside one batch cannot see each other as neighbours. The batch is 1/16 of the graph size (64–512), so there is no measured recall loss — but very small collections fall to the serial path below 1024 vectors.
- The build is parallel within a batch, and because writing links is serial the speed-up is not linear in core count: about 1.9× on eight cores.
- Ordered indexes are rebuilt from the documents and cost on
write.
@sortedkeeps about 20 bytes a row for a number, plus the text for atextfield, and none of it is in the file: two ordered indexes over a million rows took about 40 ms to build, which the first query reading each after an open pays, and took a bulk load from 0.52 s to 0.88 s. A key that grows with the id, a creation time, is appended; a random one is inserted into a sorted run of at most 512 entries. - File writes are buffered. If the process crashes before
syncorcheckpoint, the last writes can be lost. In embedded use callingsyncis the caller's job.
Query behaviour
Which filters use an index, what order and
near cost, and the few ways a query behaves differently from
what you might expect.
- Only an
andchain of equalities and ranges reaches an index;!=,~and anything underorscan every row. orderreads every match unless it is over one@sortedfield with alimit.- A vector's components are numbers its field holds: a
NaN, an infinity or1e39is refused naming the field and the element.
Edge cases of sparse near, filters, order and collation
nearover asparse<N>field ranks only the documents sharing a dimension with the query, by dot product and exactly — it takes noef. A document with no dimension in common scores nothing and is not returned, as a document holding no word of amatchquery is not; with weights of both signs, one that shares dimensions can score below zero and still be on the page. The cost grows with the query's non-zero entries: SPLADE expands a query to 40 to 65 of them, which reach most of the corpus.- Only an
andchain reaches an index — equality (=orin [..]) over a@hashfield or overid, and comparisons (<,<=,>,>=,=) over a@sortedfield.!=,~,has, a comparison on a field without@sorted, and anything under anoris a full scan: every matching row is decoded and evaluated.~is unranked substring matching; ranked retrieval ismatchover a@textfield, which does reach an index. - A
@hashequality answers as the scan does: a float's-0.0and0.0are one value, everyNaNone, and a whole float the int it is (a json field's3and3.0), inside a list too. A time against atextorjsonfield's@hashis left to the scan, which reads every text spelling a time as that time (two kinds). - A comparison reaches an ordered index only when its literal compares
exactly as the scan would:
price < 12.5on anintfield is tested row by row; an integer no float holds (253 + 1) against afloatis said by the floats either side of it. A range wider than half the collection is scanned rather than read from the index. - An
inlist reaches the index only when every element resolves to a value the field's type can express. One element it cannot —year in [2024, "abc"]— sends the whole list back to the scan, because a union missing an element's rows would be a wrong answer rather than a slow one. - A filtered
nearreads its filter's rows only until more of them match than the ANN would measure anyway (ef × m0, 3 200 at the defaults), so a filter matching many rows costs little: over 200 000 × 128,year >= 2020, 23% of the rows, takes 1.1 ms against the ANN's 0.14. A selective filter is read in full — 17.9 ms for 1% of the rows — and its set is searched exactly, so recall is 10/10. An index on the filtered field takes that scan away: 0.16 ms with@sorted. orderreads every match, unless it is over a@sortedfield and has alimit. Onlyoffset + limitrows are put in order — the rest are partitioned away in linear time — but every matching row's key is still read, since the first twenty cannot be known without seeing all of them. The cost follows the number of matches, notlimit: over a million rowsorder created desc limit 20takes 26.8 ms, and 0.001 ms oncecreatedis@sorted, because the index is walked in order and the walk stops at the page. A filter the index cannot narrow is tested on each row the walk passes, and one that has not filled the page within an eighth of the collection hands the query back to the scan — at worst about 1.25× the scan alone. An order over two keys takes the sorting path. Withoutorder, a scan stops atoffset + limitmatches.- Two collations: Unicode's root and Turkish.
collate undorders text as ICU's root collation does, for every script, andcollate tras its Turkish one; another language's own order — Swedishå ä öafterz, German phonebook order — is the root's until its tailoring is added. The order is ICU's exactly but for a mark that composes with its letter across another mark between them, or marks out of their canonical order, which ICU's normalisation finds and fennecdb sorts as marks of their own: five in 1 250 000 random pairs. A key collated in the query over a field declared in no collation is sorted rather than walked — 890 ms for a million names, against 374 ms by their bytes — and a comparison inwhereover it compares bytes; a field declared in the collation has both. In the browser a statement that needs a script's weights the module has not been handed is refused until it has them (JavaScript). nocasefolds case, and only case. Unicode's full case folding (Turkish's incollate tr), with no normalisation:éas one code point and aseand a combining accent are two texts, as arerésuméandresume, and a full-width letter is not its ASCII one. It is a text field's alone, not a list's or ajsonfield's, and a field is madenocase, or no longer, by being built again, not in place. A scan over one folds each row as far as it is compared — a name by the scan 5.5 → 6.8 ms over 100 000 rows — and an order without a@sortedindex folds each row's key once, 8.5 → 16.2 ms (Case-insensitive text).nearandordercannot be used together;neardetermines the ordering by similarity.- A query vector can be given three ways: a vector, a list, or pgvector's
text form (
near embed '[1,0,0]'), which is the natural one when typing by hand in the shell. None of the three fails silently — unparsable text and a non-numeric component both error. - A vector's components are numbers its field holds. A
component past an
f32's range —1e39, within a float's, which anf32rounds to its infinity — and aNaNor an infinity sent asf32s (aFloat32Array, the native libraries' vectors) are refused naming the field and the element, counted from 0 —field `embed`, element 3: a vector's component is a number at most 3.4028235e38 either side of 0— wherever a write takes one: a statement, a parameter, a JSON body, aset, an upsert, a named statement's argument,fennec import.near's andrerank's query vector too, naming its field. Stored, such a component came back asnull, and every distance from it was an infinity or aNaN. In avector<N, f16>field a component of 65 520 or more either side, which rounds to thef16's infinity, is refused the same way, and one at or under about 3×10-8 is 0; in avector<N>one at or under 7×10-46 is. A row an earlier version stored with aNaNor an infinity opens and reads as before, the componentnullin JSON;nearmeasures it as it is, and a function over vectors computes over it — write its vector again to put it right. A component written past a float's own range (1e400) is refused as every number is, whatever its field. - The browser module needs WebAssembly SIMD: Chrome 91, Firefox 89, Safari
16.4 (March 2023) or later. On an engine without it,
Fennec.openfails with aFennecErrorthat says so. now()does not work in the browser: wasm32-unknown-unknown has no clock and the call errors. Pass the time as a parameter withDate.now().
fennec-server
The server is one process over one file, reached over HTTP, and it serves HTTPS itself once it is given a certificate.
- HTTPS needs a certificate: without
--tls-certthe server speaks plain HTTP. What it dials itself takes anhttps://URL without one. - No interactive transactions: a
/batchis the unit that lands whole. - Too many connections are refused, not queued.
The server's limits on TLS, transactions and connections
- TLS both ways, and no client certificates. With
--tls-certand--tls-keythe HTTP and--metricslisteners speak HTTPS alone; without them a token travels in the clear on an open network. What the server dials itself — a replica's--replica-of, the router's links to its nodes, the regions' relays, the OTLP exporter, thefennec mcpbridge — dialshttps://over TLS, with no client certificates, its certificate held to Mozilla's roots or to--tls-ca's CAs in their place (Dialing HTTPS). A renewed certificate takes a restart (HTTPS). Listening on a non-loopback address with no token is refused without--insecure. - No transaction held open across requests. There is one writer,
and a transaction a client held open between its requests would hold
every other write for as long as the client took. A
/batchlands its statements whole or not at all, and anIdempotency-Keymakes it safe to retry. Acompactcannot be put back, so a batch holding one runs each statement on its own. - A running statement, such as a long
compact, is not cut in the middle; a client that goes away does not cancel it. - A ceiling, not a pool. Every connection is an OS thread.
--max-connectionsrejects the excess with 503 rather than queueing it -- once a subscription streams it is counted under--http-max-streamsinstead, except on a tenant node or at--http-max-streams 0; put a proxy in front if you want a queue. The refused client's request is read off after the 503 and its connection ended without a reset, so any HTTP library reads the answer and itsRetry-After. A connection the process can make no thread for — at its thread limit, below the ceiling — is answered the same 503, withRetry-After, and counted (fennec_connections_refused_total{reason="no_thread"}). - A keep-alive connection silent for 60 s is closed
(
--idle-timeout <s>, 0 for never). A request must come within 10 s of its first byte and a second more for each KiB that came, head and body alike -- 1 KiB a second at least (--header-timeout <s>) -- else 408; a write of an answer waits 30 s at most for its client to take any of it, so a client that reads nothing is let go within a minute (--write-timeout <s>). A slow client holds a connection's thread for its request's time, not for as long as it likes.
fennec-http
The HTTP endpoint runs inside fennec-server and keeps to a plain
subset of HTTP. Its routes, filters and statuses are on HTTP reference; this is what it leaves out.
- HTTPS needs a certificate: with
--tls-certand--tls-keythe listener speaks HTTPS alone, without them plain HTTP. Without a token it binds only to the local machine. - Bodies up to 64 MiB, by length or chunked, and paging by
limitandoffset. - Subscriptions are one-way server-sent events, not WebSockets.
The HTTP listener's limits on bodies, batches and streams
- Not a separate process. It opens as a second listener via
fennec-server --http; there is no standalone binary, because two processes opening the same file would corrupt it. - TLS is off until a certificate is given (Security).
Without a token it will not bind a non-loopback address. The
server's own token,
--http-token, is a single shared secret with full access; per-user access with scopes and expiry is a JSON Web Token held to a policy (Scoped access). - The body is capped at 64 MiB, by its
Content-Lengthor its chunks (Transfer-Encoding: chunked, each size held to the ceiling before it is read), and the header block at 64 KiB; above that, 413 or 431. A body two servers could frame two ways is 400, a transfer coding butchunked501 (Request bodies). The one body read past 64 MiB is a tenant's image installed on a node, up to 1 GiB, and only once the request's head carries the node's admin token (Sharding reference). - Pagination is
limitandoffset— no cursor, noRangeheader — each a number or, in FennecQL, a parameter (limit $2 offset $3), so every page is one statement. The response is built in one piece, so a very largeselectholds that much memory on the server. - A field whose name matches a clause name (
select,order,limit,offset,count,where) cannot be filtered from the query string.POST /queryandfennec-serverare unaffected. - No
ETag, noLast-Modified, no conditional requests. Responses are not marked cacheable. - A subscription is one-way. The server sends changes over SSE and
the client writes with ordinary
POST,PATCHandDELETE. There is no WebSocket; for the same job it would demand framing, masking and ping/pong. - A subscription refuses
order,limit,offsetandcountwith a 400: a shape is a set, not a window, and an incremental diff cannot express a moving one. - A write to any collection wakes every subscriber. That is a necessity rather than noise: the counter and the ring are shared across collections, so a subscriber to a quiet collection that did not wake would keep its cursor in place and be reseeded once other writes overflowed the ring. Waking moves the cursor forward, and no empty batch is sent for a change that does not match the shape. The cost is one read lock and an empty scan.
- A batch holding a compact is not one block. A
compactrewrites the file, which cannot be put back, so aPOST /batchholding one runs each statement on its own, stops at the first error and reports how many were applied. Every other batch — acreate, adropor acreate indexamong its statements — lands whole or not at all.
Import
fennec import copies one table into one collection, from
SQLite or PostgreSQL, and can follow a PostgreSQL table as it changes.
- Checkpoint a SQLite file's WAL first; one with an unprocessed WAL is not read.
- A vector with a NaN, an infinity or a component past what its field holds stops the import at that row.
--followneedswal_level = logicaland an integer key.
What import does not read or follow
- One table becomes one collection. Multi-table migration is out of
scope; a
JOINon a key reads as alookupafterwards. fennec importis in the default build but is a separate feature. A binary built with--no-default-featureshas no such subcommand, and says so before exiting.--wheresees only the built-in functions; plugin functions cannot be used. The filter is evaluated without borrowing the target database, so that writing can happen in the same loop.- A SQLite file with an unprocessed WAL is not read. The main file
shows stale data and stopping beats silently returning it. Run
sqlite3 <db> "PRAGMA wal_checkpoint(TRUNCATE)"first.WITHOUT ROWIDtables are not read either. - No md5 authentication: scram-sha-256 or cleartext. A server asking
SCRAM for more than 4 194 304 iterations is refused, the range named:
set the role's password again under a lower
scram_iterations. - PostgreSQL
timestamp(tz)values are truncated to milliseconds. - A non-finite component of a value bound for a vector field stops
the import — a pgvector column, a BLOB under
--vector, afloat[]named with it — and it says which row, as does a component past what the field holds: afloat8[]'s1e39, whosef32is an infinity, or one of 65 520 or more bound for avector<N, f16>. A NaN makes a distance incomparable; even if the index accepted it, the result would be meaningless. Afloator[float]field keeps itsNaNs and infinities, as PostgreSQL holds them; a decimal past a float's range, anumeric's1e400, stops it naming the row and the column. - An import that stops halfway cannot be rolled back — there are no transactions.
--followneedswal_level = logicaland an integer key in the replica identity: a changed row has to be found again by id. It holds its file as its only writer, and its slot holds the server's log until confirmed — drop the slot when you stop following for good (Following changes).- A column added to the followed table after the copy is left out; one the collection needs that is dropped from it stops the follower.