Description
Describe the bug
When querying only for totalCount
within a *Connection
query, database-internal data is returned for each found node-instance resulting in a HUGE response. This totally kills the performance when having many nodes.
See the steps to reproduce. When running this query on our production database with Neo4j Desktop, the app completely dies and shuts down. And we only have around 2m nodes of this type. We have other types with ~80m nodes. Don't want to know what would happen if I executed this query on that type...
Type definitions
type Norm {
code: String!
}
To Reproduce
- Run a server with the type defs
- Execute the following Query:
query {
normsConnection {
totalCount
}
}
- The following cypher is generated
MATCH (this0:Norm)
WITH collect({ node: this0 }) AS edges
WITH edges, size(edges) AS totalCount
CALL {
WITH edges
UNWIND edges AS edge
WITH edge.node AS this0
RETURN collect({ node: { __id: id(this0), __resolveType: "Norm" } }) AS var1
}
RETURN { edges: var1, totalCount: totalCount } AS this
- This results in a response with the following structure:
{
"edges": [
{
"node": {
"__resolveType": "Norm",
"__id": 42942
}
},
{
"node": {
"__resolveType": "Norm",
"__id": 47617
}
},
....
],
"totalCount": 185
}
- The sub-object
node
with the keys__resolveType
and__id
is returned for EACH found instance.
Expected behavior
When querying on a connection including only totalCount
, the irrelevant meta-information should NOT be returned to keep perfomance.
Even to query for is a perfomance killer, I think.
A simple cypher to aim for the count-store only should be sufficient:
MATCH (this0:Norm)
RETURN {totalCount:count(this0)}
System
- Version: @neo4j/[email protected]