{
  "slug": "prefix-extractor",
  "term": "Prefix extractor",
  "aliases": [
    "Key prefix transform"
  ],
  "definition": "A key transformation with a defined input domain that produces the prefix used for prefix-based indexing or filtering.",
  "note": "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. [prefix-transform]\n\nEqual-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. [prefix-order-api]\n\nSeeking 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. [prefix-transform] After a restart with a different extractor, files that record another extractor name usually have their prefix filters ignored. [prefix-seek-wiki]",
  "related": [
    "prefix-bloom-filter",
    "bloom-filter",
    "succinct-range-filter"
  ],
  "citations": [
    {
      "id": "prefix-transform",
      "title": "RocksDB v9.7.3. SliceTransform: domain, append stability and fixed, capped and no-op extractor contracts.",
      "url": "https://github.com/facebook/rocksdb/blob/v9.7.3/include/rocksdb/slice_transform.h",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela",
      "title": "Hesela: prefix order counterexamples and exact-set checks",
      "url": "https://hesela.com/analyses/bloom-filters-lsm-read-cost/#prefix-order",
      "accessed": "2026-10-20"
    },
    {
      "id": "prefix-order-api",
      "title": "RocksDB v9.7.3: prefix_extractor contiguity requirement",
      "url": "https://github.com/facebook/rocksdb/blob/v9.7.3/include/rocksdb/options.h",
      "accessed": "2026-10-20"
    },
    {
      "id": "prefix-seek-wiki",
      "title": "RocksDB wiki: Prefix Seek; read modes, prefix extractor changes and prefix iteration limits.",
      "url": "https://github.com/facebook/rocksdb/wiki/Prefix-Seek",
      "accessed": "2026-10-23"
    }
  ],
  "status": "shipping",
  "advantages": [
    {
      "text": "A matching extractor lets prefix scans skip files whose filter shows no key with the requested prefix.",
      "citationIds": [
        "prefix-seek-wiki"
      ]
    }
  ],
  "limitations": [
    {
      "text": "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.",
      "citationIds": [
        "prefix-transform"
      ]
    },
    {
      "text": "Iterating past the prefix range in plain prefix mode returns undefined results without an error.",
      "citationIds": [
        "prefix-seek-wiki"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-23",
  "provenance": [
    "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."
  ]
}
