Skip to content

6115 total count only connection #6554

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

Merged
merged 9 commits into from
Aug 12, 2025
Merged

Conversation

angrykoala
Copy link
Member

@angrykoala angrykoala commented Aug 6, 2025

Description

Cypher optimisation on queries with only totalCount. For example:

query {
    moviesConnection(where: { title: { eq: "Forrest Gump" } }) {
        totalCount
    }
}

With this changes, the Cypher avoids querying the actual nodes to improve query performance and networking

@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Aug 6, 2025

Performance Report

name dbHits old dbHits time (ms) old time (ms) maxRows
🟦 connections.totalCount 1 N/A 17 N/A 1

🟥 - Performance worsened (dbHits)
🟩 - Performance improved (dbHits)
🟦 - New test

Show Full Table
name dbHits old dbHits time (ms) old time (ms) maxRows
aggregations.TopLevelAggregateWithMultipleFields 7936 7936 58 72 1134
aggregations.NestedAggregation 15407 15407 71 100 2174
aggregations.AggregationWithWhere 10833 10833 47 64 2174
aggregations.AggregationWhereWithinNestedRelationships 20097917 20097917 1948 2006 2008534
aggregations.AggregationWhereWithinNestedConnections 20097917 20097917 1960 2031 2008534
aggregations.InterfacesAggregations 8324 8324 111 139 2080
aggregations.InterfacesAggregationsWithTwoFields 13526 13526 127 159 2080
connections.Connection 12951 12951 68 83 2174
connections.NestedConnection 37705 37705 125 163 4516
🟦 connections.totalCount 1 N/A 17 N/A 1
cypher-directive-mutation.TopLevelMutationDirective 1135 1135 28 30 1134
cypher-directive.TopLevelSortWithCypher 12961 12961 42 51 2174
cypher-directive.TopLevelConnectionSortWithCypher 12961 12961 60 81 2174
cypher-directive.TopLevelSortWithCypherWithNested 13096 13096 64 84 2174
cypher-directive.TopLevelConnectionSortWithCypherWithNested 13096 13096 94 134 2174
cypher-directive.TopLevelSortWithExpensiveCypher 13725 13725 111 139 2174
cypher-directive.TopLevelConnectionSortWithExpensiveCypher 13266 13266 101 120 2174
fulltext.Fulltext 80 80 47 56 16
fulltext.FulltextWithNestedQuery 516 516 69 81 84
1262.NestedConnectionWhere 8703 8703 55 72 2174
187.QueryWhere 8564 8564 37 45 2154
2871.NestedRelationshipFilter 19632 19632 57 62 4395
batch-create.BatchCreate 3600 3600 85 100 600
connect.createAndConnect 4410 4410 97 64 1134
create.SimpleMutation 6 6 29 34 1
delete.SimpleDelete 19401 19401 641 631 1040
delete.NestedDeleteInUpdate 14688 14688 121 157 1179
update.NestedUpdate 10129 10129 61 76 2002
query.SimpleQuery 3121 3121 23 24 1040
query.SimpleQueryWithRelationship 15031 15031 46 52 2174
query.SimpleQueryWithNestedWhere 8713 8713 53 65 2154
query.Nested 3988 3988 75 88 1040
query.OrFilterOnRelationships 36730 36496 171 202 1955
query.OrFilterOnRelationshipsAndNested 26719 26531 212 232 1955
query.QueryWithNestedIn 14192 14189 58 68 1864
query.DeeplyNestedConnectionWhere 8702 8702 71 101 2174
query.DeeplyNestedWithRelationshipFilters 17357 17357 136 179 1552
query.NestedWithRelationshipSingleFilters 3808 3808 153 212 1134
sorting.SortMultipleTypes 3436 3436 84 104 1040
sorting.SortMultipleTypesWithCypherWithCypher 13321 13321 103 115 2174
sorting.SortOnNestedFields 12951 12951 48 55 2174
sorting.SortDeeplyNestedFields 39785 39785 104 99 4516
sorting.ConnectionWithSort 3271 3271 71 82 1040
unions.SimpleUnionQuery 321 321 61 68 35
unions.SimpleUnionQueryWithMissingFields 293 293 59 65 35
unions.NestedUnion 309975 309975 255 271 33033
unions.NestedUnionWithMissingFields 283949 283949 246 282 33033

Old Schema Generation: 26.729s
Schema Generation: 26.187s
Old Subgraph Schema Generation: 29.284s
Subgraph Schema Generation: 29.081s

@angrykoala angrykoala marked this pull request as draft August 6, 2025 12:53
MacondoExpress
MacondoExpress previously approved these changes Aug 6, 2025
Copy link

changeset-bot bot commented Aug 6, 2025

🦋 Changeset detected

Latest commit: 8726ceb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@neo4j/graphql Patch

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

@angrykoala angrykoala force-pushed the 6115-total-count-only-connection branch from 0d3de4e to fa5d1ef Compare August 7, 2025 08:55
@angrykoala angrykoala marked this pull request as ready for review August 7, 2025 08:55
@angrykoala angrykoala merged commit 70f60a2 into dev Aug 12, 2025
41 checks passed
@angrykoala angrykoala deleted the 6115-total-count-only-connection branch August 12, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants