Skip to content

Foreign key indexes#250

Merged
haveyaseen merged 5 commits intoredux-orm:masterfrom
haveyaseen:foreign_key_indexes
Mar 26, 2019
Merged

Foreign key indexes#250
haveyaseen merged 5 commits intoredux-orm:masterfrom
haveyaseen:foreign_key_indexes

Conversation

@haveyaseen
Copy link
Collaborator

@haveyaseen haveyaseen commented Mar 24, 2019

Continuation of #78 and #88 and Elijen@d965959 / Elijen@ac7ff12. Actually I didn't notice @Elijen's contributions before writing this so there may be some further improvements to take from them.

Currently the indexes are only appended during row creation, updates and deletes are still ignored.

Selectors will need to be updated as well, to account for the fact that we use indexes to optimize foreign key lookups. Then we can prevent full-table scans for simple queries like author.books.

Didn't perform performance benchmarks yet.

Currently they're only appended during row creation, updates and deletes are still ignored.
@haveyaseen haveyaseen added type: Enhancement This intends to enhance the project. status: WIP Someone is working on this issue. layer: Schema layer: Database layer: Selectors labels Mar 24, 2019
@haveyaseen haveyaseen changed the title Add foreign key indexes Foreign key indexes Mar 24, 2019
Require all accessed foreign key indexes to be equal for memoization.
There is still an issue causing extremely long removal times, at least for many-to-many relationships.
…indexes.

Allow marking indexes as accessed through Model instance.

Use an `index` property in Field objects to determine whether or not to index on columns.
This removes the need for the table implementation to know about the ForeignKey class and allows for better extensibility for potential other uses of indexes.

Add tests that ensure indexes are updated correctly.

Improve comments in memoize function.
@haveyaseen
Copy link
Collaborator Author

haveyaseen commented Mar 26, 2019

Many-to-many queries don't fully leverage the foreign key indexes yet:
https://github.com/tommikaikkonen/redux-orm/blob/eddc4516157c184ad6233e947711e50467fb6a11/src/descriptors.js#L174-L192
While the throughQs.toRefArray() query is optimized by default using a foreign key index, the final query OtherModel.filter() uses a function which prevents us from optimizing it. Some joining capabilities are necessary for an improved API, and then we can heavily optimize those queries as well.

@haveyaseen haveyaseen removed the status: WIP Someone is working on this issue. label Mar 26, 2019
@haveyaseen haveyaseen merged commit b9c1635 into redux-orm:master Mar 26, 2019
@haveyaseen haveyaseen deleted the foreign_key_indexes branch March 26, 2019 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant