Skip to content

Commit 93c9bc7

Browse files
samwilliskevin-dp
andauthored
Predicate Comparison and Merging Utilities for Predicate Push-Down (#668)
* Add unit tests that reproduce the problems with moveWindow on infinite limits * Handle Infinity limit in move * Changeset * Add support for orderBy and limit options in currentStateAsChanges * Unit tests for currentStateAsChanges * changeset * fix for eslint * Move helper functions to the end of the file * add predicate utils * optimise in when all primatives * optimisations * changeset * minusWherePredicates * Add unit test for OR in both subset and superset that shows bug with OR handling * Reorder OR handling to fix bug and handle AND similarly * change chageset * dedupe code * add createDeduplicatedLoadSubset function * convert deduper to a class, with reset, and dedupe inflight * Simplify matching of inflight requests * Improve minusWherePredicates such that it can handle common conditions in a conjunction * Modify DeduplicatedLoadSubset.loadSubset such that it only loads the missing data * Remove unused predicate helper functions * Fix eslint issue * Prettier * Unify handling of IN and OR * Handle subset that is false * Fix isLimitSubset to correctly handle unlimited subsets --------- Co-authored-by: Kevin De Porre <[email protected]>
1 parent 2985ab8 commit 93c9bc7

File tree

8 files changed

+3347
-0
lines changed

8 files changed

+3347
-0
lines changed

.changeset/legal-cooks-sink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tanstack/db-ivm": patch
3+
---
4+
5+
Fix bug with setWindow on ordered queries that have no limit.

.changeset/light-phones-flash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tanstack/db": patch
3+
---
4+
5+
Add predicate comparison and merging utilities (isWhereSubset, intersectWherePredicates, unionWherePredicates, and related functions) to support predicate push-down in collection sync operations, enabling efficient tracking of loaded data ranges and preventing redundant server requests. Includes performance optimizations for large primitive IN predicates and full support for Date objects in equality, range, and IN clause comparisons.

.changeset/open-cups-lose.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tanstack/db": patch
3+
---
4+
5+
Add support for orderBy and limit in currentStateAsChanges function

packages/db/src/query/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,15 @@ export {
5757

5858
export { type LiveQueryCollectionConfig } from "./live/types.js"
5959
export { type LiveQueryCollectionUtils } from "./live/collection-config-builder.js"
60+
61+
// Predicate utilities for predicate push-down
62+
export {
63+
isWhereSubset,
64+
unionWherePredicates,
65+
minusWherePredicates,
66+
isOrderBySubset,
67+
isLimitSubset,
68+
isPredicateSubset,
69+
} from "./predicate-utils.js"
70+
71+
export { DeduplicatedLoadSubset } from "./subset-dedupe.js"

0 commit comments

Comments
 (0)