Operator-installed partial index bounding native pending selection.
Publication removes the pending marker key, so an index restricted to rows
that carry it holds the unpublished set, not committed history. Selectors add
the literal key-existence predicate so every plan, generic or custom, can prove
the index applies. Rows whose marker is present but falsey stay in the index
and are still visited; Symfonic writers never persist one. Dead tuples still
cost until vacuum, which is why the selectors keep their execution deadline.
marked
marked(column: str = 'properties') -> str
Key-existence predicate implying the partial index; internal SQL only.
Source code in src/symfonic/memory/backends/postgres_pending_index.py
| def marked(column: str = "properties") -> str:
"""Key-existence predicate implying the partial index; internal SQL only."""
return f"{column} ? '{PENDING_KEY}'"
|
require_pending_index
async
require_pending_index(conn: Any) -> None
Refuse a missing, invalid, differently keyed or collated pending index.
Source code in src/symfonic/memory/backends/postgres_pending_index.py
| async def require_pending_index(conn: Any) -> None:
"""Refuse a missing, invalid, differently keyed or collated pending index."""
valid = await conn.fetchval(
"SELECT i.indisvalid AND i.indisready AND i.indislive "
"AND i.indrelid='memory_nodes'::regclass AND NOT i.indisunique "
"AND i.indnkeyatts=2 AND i.indnatts=2 "
"AND i.indexprs IS NULL AND i.indpred IS NOT NULL "
"AND pg_get_expr(i.indpred, i.indrelid)=$2 AND am.amname='btree' "
"AND a0.attname='tenant_id' AND a1.attname='scope_path' "
"AND i.indcollation[0]='pg_catalog.\"C\"'::regcollation "
"AND i.indcollation[1]='pg_catalog.\"C\"'::regcollation "
"AND i.indoption[0]=0 AND i.indoption[1]=0 "
"AND o0.opcname='text_ops' AND o0.opcnamespace='pg_catalog'::regnamespace "
"AND o1.opcname='text_ops' AND o1.opcnamespace='pg_catalog'::regnamespace "
"FROM pg_index i JOIN pg_class c ON c.oid=i.indexrelid "
"JOIN pg_am am ON am.oid=c.relam "
"JOIN pg_attribute a0 ON a0.attrelid=i.indrelid AND a0.attnum=i.indkey[0] "
"JOIN pg_attribute a1 ON a1.attrelid=i.indrelid AND a1.attnum=i.indkey[1] "
"JOIN pg_opclass o0 ON o0.oid=i.indclass[0] "
"JOIN pg_opclass o1 ON o1.oid=i.indclass[1] "
"WHERE i.indexrelid=to_regclass($1)",
PENDING_INDEX, _PREDICATE,
)
if valid is not True:
raise RuntimeError("CORE-199 pending index missing or invalid")
|