docs: equality on ordering domains splits on term injectivity#418
Conversation
The database-indexes page claimed equality rides eq_term/hm on the _ord domains generally. The shipped 3.0.2 bundle disagrees for the numeric-and-time types: their ordering terms (OPE and ORE alike) are injective, so those _ord/_ord_ore domains carry no hm, define no eq_term overload, and eql_v3.eq inlines to an ordering-term comparison — one ordering btree serves = and range. Text ordering terms are non-injective and cannot be relied on for equality, so text_ord/text_ord_ore (and the text_search variants) carry hm and answer = via eq_term. Corrected in five places (the recipe comment, requirement 1, the equality query pattern — now with the numeric-_ord engagement example — the term-check troubleshooting item, and the zero-rows note), plus a new note stating the injectivity rule once. Found while porting this guide into the stash agent skill (cipherstash/stack#753 / cipherstash/stack#773): an eq_term index recommended for a numeric _ord column doesn't compile (no overload), and the "type the column as _ord for equality" guidance pointed users at an index that can't exist. Claude-Session: https://claude.ai/code/session_01BkEpKJC3975NHsKgMrCT8R
|
Warning Review limit reached
Next review available in: 35 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the database indexing guide to accurately document how equality predicates are served for ordering-capable encrypted domains, reflecting the current shipped eql_v3 SQL surface (numeric/time _ord equality via ordering terms; text ordering domains via hm/eq_term due to non-injective ordering terms).
Changes:
- Corrects the “Equality” index recipe and all affected references to list only the
hm-carrying domains as eligible foreql_v3.eq_term(...)indexes. - Adds an explicit note explaining the injectivity split: numeric/time ordering terms are injective (so
=usesord_term/ ordering btree), while text ordering terms are not (so=relies oneq_term/hm+ equality index). - Updates “Index Usage Requirements”, “Equality Queries”, and “Troubleshooting” to match the above behavior and avoid recommending DDL that cannot work (missing overloads).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Docs only change. |
Problem
docs/reference/database-indexes.mdclaims equality rideseq_term/ thehmterm on the_orddomains generally:public.<T>_eq/_ord/text_search"hm(hmac_256) term —public.<T>_eq,public.<T>_ord, …"public.<T>_eq(or_ord, ortext_search)"The shipped 3.0.2 bundle disagrees for the numeric-and-time types. Verified against
cipherstash-encrypt.sqlat this release:The underlying design: numeric-and-time ordering terms (OPE and ORE alike) are injective, so equality can ride the ordering term — those domains carry no
hm. Text ordering terms are non-injective and cannot be relied on for equality, so the text ordering domains carryhmas well.As written, the doc recommends an
eq_termindex for a numeric_ordcolumn — DDL that fails outright (no overload) — and implies_ordtyping is an equality-via-hmpath, when the index that actually serves=on those columns is the ordering btree.Change
Docs-only, five spots corrected + one new note stating the injectivity rule once:
hm-carrying domain list (_eq/text_ord/text_ord_ore/text_search/text_search_ore).eq_termindex on a numeric_ordcolumn; the overload does not exist."_ordengagement example (Index Cond: (eql_v3.ord_term(…) = eql_v3.ord_term($1))against the range-recipe index).=-returns-zero-rows entry → same split.How this was found
Porting this guide into the
stashagent skill (cipherstash/stack#753, cipherstash/stack#773): a Drizzle helper that derives index DDL from the per-domain capability records emitted noeq_termindex forIntegerOrd/DateOrdcolumns, which disagreed with this page — the bundle turned out to be the one telling the truth.https://claude.ai/code/session_01BkEpKJC3975NHsKgMrCT8R