defradb
defradb copied to clipboard
Sec. index: enable indexing of related objects
At the moment with requests like:
query {
Device(filter: {
owner: {name: {_eq: "Keenan"}}
}) {
model
}
}
and schema:
type User {
name: String @index
devices: [Device]
}
type Device {
model: String
owner: User
}
the index will find and fetch the owner right away but having no reference to secondary objects (devices) we have to do full scan of devices to see which of them have corresponding owner_id
.
The use cases from the following (potentially others as well) tests suffer from not utilizing indexes on related objects.
TestQueryWithIndexOnOneToOnePrimaryRelation_IfFilterOnIndexedFieldOfRelation_ShouldFilter
TestQueryWithIndexOnOneToOnePrimaryRelation_IfFilterOnIndexedRelationWhileIndexedForeignField_ShouldFilter
TestQueryWithIndexOnOneToMany_IfFilterOnIndexedRelation_ShouldFilterWithExplain
TestQueryWithIndexOnOneToOne_IfFilterOnIndexedRelation_ShouldFilter
TestQueryWithIndexOnManyToOne_IfFilterOnIndexedRelation_ShouldFilterWithExplain
This task potentially covers #2578