{
  "slug": "partial-index",
  "term": "Partial index",
  "aliases": [],
  "definition": "A partial index stores entries only for table rows that satisfy a specified predicate.",
  "note": "SQLite includes a row only when the index predicate is true; false and NULL exclude it. The predicate may reference a column absent from the index key. [sqlite-partial]\n\nUNIQUE constrains the selected subset, not the whole table. NULL-key handling is a separate rule: SQLite treats NULL keys as distinct. Updating a row into the subset must also satisfy uniqueness. [sqlite-create]\n\nQuery eligibility requires the planner to recognize that the query implies the predicate; logical equivalence alone need not suffice. SQLite forbids parameters in the index definition, not every parameterized query using it. [sqlite-partial]\n\nSQLite permits only deterministic functions in the predicate. Labeling a changing application function deterministic does not make its results stable or preserve valid index contents. [deterministic]\n\nPostgreSQL can use custom plans with supplied parameter values or generic plans that retain parameters. A parameter-dependent implication cannot be assumed valid for every value. [pg-partial] [pg-prepare]\n\nA 1989 proposal also used partial predicates to track incremental index construction and rebuilding; those ideas require optimizer support, not just several small indexes. [stonebraker]",
  "related": [
    "sqlite-expression-index",
    "b-tree"
  ],
  "citations": [
    {
      "id": "sqlite-partial",
      "title": "SQLite: Partial Indexes, membership and planner rules",
      "url": "https://www.sqlite.org/partialindex.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "sqlite-create",
      "title": "SQLite: CREATE INDEX, unique and partial indexes",
      "url": "https://www.sqlite.org/lang_createindex.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "deterministic",
      "title": "SQLite: Deterministic SQL Functions, index restrictions",
      "url": "https://www.sqlite.org/deterministic.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "pg-partial",
      "title": "PostgreSQL 17: Partial Indexes, implication at planning time",
      "url": "https://www.postgresql.org/docs/17/indexes-partial.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "pg-prepare",
      "title": "PostgreSQL 17: PREPARE, generic and custom plans",
      "url": "https://www.postgresql.org/docs/17/sql-prepare.html",
      "accessed": "2026-11-18"
    },
    {
      "id": "stonebraker",
      "title": "Stonebraker: The Case for Partial Indexes, UCB/ERL M89/17 (1989), sections 3.1-3.4",
      "url": "https://www2.eecs.berkeley.edu/Pubs/TechRpts/1989/ERL-89-17.pdf",
      "accessed": "2026-11-18"
    },
    {
      "id": "hesela",
      "title": "Hesela: partial-index membership and uniqueness controls",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#partial-index-membership",
      "accessed": "2026-11-18"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-18",
  "provenance": [
    "Primary documentation synthesis. PostgreSQL plan qualification combines its partial-index and PREPARE documentation; no PostgreSQL execution or performance claim. Linked SQLite demonstration uses constructed rows, not field data.",
    "Historical design proposal read in full; cost-model examples are not modern engine benchmarks. [stonebraker]"
  ]
}
