You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(db): simplify indexing with BasicIndex and explicit defaultIndexType
- Add BasicIndex using Map + sorted Array for both equality and range queries
- Remove registry pattern - pass defaultIndexType to collection constructor instead
- Remove lazy index infrastructure (LazyIndexWrapper, IndexProxy)
- Simplify indexing.ts entry point to just export BasicIndex and BTreeIndex
- Update all tests to explicitly set defaultIndexType where needed
- Update changeset to reflect simplified approach
Breaking changes:
- createIndex() requires defaultIndexType on collection or indexType in config
- enableIndexing()/enableBTreeIndexing() removed, use defaultIndexType instead
Copy file name to clipboardExpand all lines: .changeset/optional-indexing.md
+31-15Lines changed: 31 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,43 +2,59 @@
2
2
"@tanstack/db": minor
3
3
---
4
4
5
-
Make indexing optional with two index types for different use cases
5
+
Make indexing explicit with two index types for different use cases
6
6
7
7
**Breaking Changes:**
8
8
-`autoIndex` now defaults to `off` instead of `eager`
9
9
-`BTreeIndex` is no longer exported from `@tanstack/db` main entry point
10
+
- To use `createIndex()` or `autoIndex: 'eager'`, you must set `defaultIndexType` on the collection
10
11
11
12
**Changes:**
12
13
- New `@tanstack/db/indexing` entry point for tree-shakeable indexing
13
-
-**MapIndex** - Lightweight index for equality lookups (`eq`, `in`). Range queries (`gt`, `lt`, etc.) fall back to scanning.
14
-
-**BTreeIndex** - Full-featured index with range queries and sorted iteration for ORDER BY optimization
15
-
-`enableIndexing()` - Uses MapIndex (lightweight, for most use cases)
16
-
-`enableBTreeIndexing()` - Uses BTreeIndex (for ORDER BY on large collections 10k+ items)
14
+
-**BasicIndex** - Lightweight index using Map + sorted Array for both equality and range queries (`eq`, `in`, `gt`, `gte`, `lt`, `lte`). O(n) updates but fast reads.
15
+
-**BTreeIndex** - Full-featured index with O(log n) updates and sorted iteration for ORDER BY optimization on large collections (10k+ items)
17
16
- Dev mode suggestions (ON by default) warn when indexes would help
18
17
19
18
**Migration:**
20
19
21
-
If you were relying on auto-indexing, choose an approach based on your needs:
20
+
If you were relying on auto-indexing, set `defaultIndexType`on your collections:
22
21
23
-
1.**Lightweight indexing** (equality lookups, range queries fall back to scan):
22
+
1.**Lightweight indexing** (good for most use cases):
0 commit comments