Custom string collation: opt-in to trust the provider's order, so ordered windows page instead of loading the full source
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- database
Research direction
Start with the custom string collation handling added in #1904, then trace requiresFullSource, computeSubscriptionOrderByHints, canExpressCursorOrder, and the cursor comparison functions. The issue describes tests for bounded first-page queries, collated cursor paging, untrusted collations, and comparison identity; use those cases to check that trusted provider ordering enables paging while the default remains unchanged.
Written by the indexing model from the issue text.
Description
Since #1904, a custom string collation ({ stringSort: 'custom', compare }) marks every ordered query requiresFullSource, and computeSubscriptionOrderByHints drops orderBy/limit. That is the safe default when the backend's order is unknown. But some backends order strings with exactly that collation: InstantDB answers ordered/limited queries in Postgres glibc en_US, and our comparator matches it row for row (verified on 5,519 live rows).
Today those backends have two options. They can sort lexically, which gives the wrong pages. Or they can use the custom collation, and then every ordered window, on any field, requests its whole filtered source, because the collection default applies to every clause.
Proposal: an opt-in on the custom collation:
defaultStringCollation: {
stringSort: 'custom',
compare: comparePostgresText,
trustProviderOrder: true,
}
With it set:
requiresFullSourceand the subscription hints treat the order as provider-pageable, as for lexical order.canExpressCursorOrderaccepts string values under it.- The cursor's
gt/ltcarry the collation, so local evaluation agrees with the provider.gt/gte/lt/ltetake an optionalCustomStringCollationthird argument, stored on theFunc(not as an argument, so query identity still hashes; its identity is canonicalized like an orderBy collation).
Index range optimization skips collated comparisons.
Without the flag nothing changes. We have this implemented on top of 0.15.2 with tests (bounded first page, collated cursor paging, untrusted collations unchanged, comparison identity), and the full @tanstack/db suite passes. Happy to open a PR.
- Dominant language
- TypeScript
- Stars
- 4k
- Forks
- 277
- Avg merge
- 18h 49m
- Merged PRs (30d)
- 224
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TanStack/db
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
OfflineExecutor.dispose() never settles pendingTransactionPromisesPossibly taken @Claire-ovo claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TanStack/db#2254 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
Maintainers usually reply within 1 day
Similar issues
-
backend refactor
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
NIAEFEUP/tts#927 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
callstackincubator/react-native-harness#296 ·
Maintainers usually reply within 1 day
-
status:in-linear
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
n8n-io/n8n#42293 · 1 comment ·
Maintainers usually reply within 1 day
-
verified
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 5 days
-
Add inputmode attribute support (forwarded to the inner input)May be free again A pull request for this issue was closed without being merged. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Neovici/cosmoz-input#467 ·
Maintainers usually reply within 1 day