-
Notifications
You must be signed in to change notification settings - Fork 109
Enable auto-indexing for nested field paths #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable auto-indexing for nested field paths #728
Conversation
This fix allows auto-indexes to be created for nested field paths (e.g., `profile.score`, `metadata.stats.views`), not just top-level fields. This resolves performance issues where queries with `eq()`, `gt()`, etc. on nested fields were forced to do full table scans instead of using indexes. Changes: - Remove the `fieldPath.length !== 1` restriction in `extractIndexableExpressions()` - Update `ensureIndexForField()` to properly traverse nested paths when creating index accessors - Add comprehensive tests for nested path auto-indexing with 1, 2, and 3-level nesting - Verify that nested path indexes are properly used by the query optimizer Fixes #727 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: f44b33a The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: +63 B (+0.07%) Total Size: 84.5 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 2.89 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for the naming of the auto indexes - that plus a changeset and it will be good to merge.
| return current | ||
| }, | ||
| { | ||
| name: `auto_${fieldPath.join(`_`)}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I like the naming of the index by replacing of the periods with underscores. It could product a conflict.
Maybe these automatic indexes should be named "auto:path.to.field" - no chance of a conflict.
Change auto-index naming from 'auto_field_path' to 'auto:field.path' to prevent ambiguity between nested paths and fields with underscores. Examples: - user.profile -> auto:user.profile - user_profile -> auto:user_profile (no conflict!) Co-authored-by: Sam Willis <sam.willis@gmail.com>
|
🎉 This PR has been released! Thank you for your contribution! |
This fix allows auto-indexes to be created for nested field paths (e.g.,
profile.score,metadata.stats.views), not just top-level fields. This resolves performance issues where queries witheq(),gt(), etc. on nested fields were forced to do full table scans instead of using indexes.Changes:
fieldPath.length !== 1restriction inextractIndexableExpressions()ensureIndexForField()to properly traverse nested paths when creating index accessorsFixes #727
🤖 Generated with Claude Code
🎯 Changes
✅ Checklist
pnpm test:pr.🚀 Release Impact