-
Notifications
You must be signed in to change notification settings - Fork 15
Description
We are using v6 and have seen some significant performance issues with some of our relationship queries. We would like to avoid those issues when migrating to v7 but the documentation does not seem to cover our issue - or even suggest it may be an issue.
The v7 documentation provides the graphqQL syntax and examples for both Relationship Filtering and AggregationFiltering but it is unclear which of those to use when you just wish to filter by the presence, or absence, of relationships.
For example, we have approximately 250,000 infrastructure records stored in our Neo4J database that may, or may not, be linked to systems. We would like an efficient query to check for orphans 🤔
The v7 documentation provides Relationship filtering:
{
infrastructure_component (
where: {
attached_systems: {
none: {
not: {
id: null
}
}
}
}
) {
id
}
}
But that seems to rely on us checking for none against the reverse of a positive connection - i.e. none of the connections are to null !
Or we can use an aggregation filter:
{
infrastructure_component (
where: {
attached_systems_connection: {
aggregate: {
count: {
nodes: {
eq: 0
}
}
}
}
}
) {
id
}
}
But is that efficient, since it has to count all the connections before it can respond?
In v5 I think we could just check for the relationship field being null - ie. (where: { attached_systems: null } ).
In or v5/v6 tests we have seen:
- The
{ systemAggregate: { count: 0 } }syntax for n..1 takes multiple seconds to run whereas:{ system: null }finishes in milliseconds. - The
{targetsAggregate: { count: 0 } }syntax for n...m takes multiple seconds to run whereas:{targets_NONE: {NOT:{code_EQ:null }}}finishes in milliseconds.
Could you please publish a recommendation/example using the new v7 syntax under a new heading entitled 'Checking For the Existence of Relationships'.
Many Thanks.