neo4j-graphql-java icon indicating copy to clipboard operation
neo4j-graphql-java copied to clipboard

Inefficient ORDER BY / LIMIT / OFFSET

Open yarc opened this issue 3 years ago • 1 comments

I have had to hack the cypher produced for queries in order to take full advantage of the FILTER_AS_MATCH when using first/limit.

I take the ORDER BY, LIMIT and OFFSET which are at the end of the RETURN statement, and move them before the RETURN (adding a WITH * to make it work). This results in ~10x fewer DB hits on our data. This is doubly important in cases where we have a lot of sub-selections in the query. There is no point loading all of the relations for this label in the database, only to return the first 5 nodes.

I have no idea if it works for all your use cases like it did mine, but the improvement is significant enough for me to bring it up.

yarc avatar Nov 16 '21 20:11 yarc

@yarc Can you please provide a testcase with the expected query.

Andy2003 avatar Nov 16 '21 23:11 Andy2003