Prefix extractor
A key transformation with a defined input domain that produces the prefix used for prefix-based indexing or filtering.
Keys outside the domain are neither added to nor queried against prefix filters. A fixed-length extractor of 4 bytes excludes a 3-byte key, while a capped-length extractor accepts every key and returns at most the cap. A no-op transform returns the whole key. Do not infer a bytewise query contract from a character count. [1]
Equal-prefix keys must form one contiguous comparator interval, with no out-of-domain interruption. In a suffix-first order, cat:1 < dog:2 < cat:3 violates a first-three-byte grouping. Passing finite examples does not establish compatibility for unseen keys. [3]
Seeking a bare prefix is safe only when appending bytes leaves the extracted prefix unchanged. With an extractor that returns text up to the first comma, abc, qualifies but abc does not: a stored key abcd,e has prefix abcd, and a filter could skip its file. The interface default answers no, which is always safe. [1] After a restart with a different extractor, files that record another extractor name usually have their prefix filters ignored. [4]
Relations
Advantages
- A matching extractor lets prefix scans skip files whose filter shows no key with the requested prefix. [4]
Limitations
- An automatic prefix mode meant to match total-order results is documented as insufficient in some upper-bound cases, so prefix seeks still need explicit review. [1]
- Iterating past the prefix range in plain prefix mode returns undefined results without an error. [4]
Citations
- RocksDB v9.7.3. SliceTransform: domain, append stability and fixed, capped and no-op extractor contracts.
- RocksDB v9.7.3: prefix_extractor contiguity requirement
- RocksDB wiki: Prefix Seek; read modes, prefix extractor changes and prefix iteration limits.
Further reading
Sources & caveats
- prefix-transform re-read 2026-10-23 for the domain rule, the 4-byte example, append stability and the fixed, capped and no-op factories.
- prefix-seek-wiki read 2026-10-23 for prefix and total-order read modes, extractor changes across restarts and undefined out-of-range iteration.
- The succinct-range-filter entry links here because a prefix filter serves a range query only when the range lies inside one extracted prefix.
- A companion analysis on prefix order counterexamples is listed but not used in prose.