Skip to content

Conversation

fickludd
Copy link
Contributor

New Cypher operator for improved handling of longer var-length expands with distinct start node / end node combinations. This new operator is called FullPruningVarExpand, and is planned for var-lengths above 4..5. Above this length the FullPruningVarExpand gives improved execution times in most cases, with speed-ups of an order of magnitude or more on even longer var-lengths.

changelog: Improved cypher execution speed on variable length queries where only the distinct pairs of start and end node are of interest. One query to benefit would be MATCH (a)-[*4..5]->(b) RETURN DISTINCT a, b.

This is an extended version of the Pruning Var Expand algorithm, improving
performance on paths with a max length of 5 or more, on randomized graphs.

The Full Pruning Var Expand (FullPrune) manages to prune paths below the min-length
by storing emit-state for all touched nodes, apart from the full expand depths. This
also makes the algorithm fully distinct, so no additional distinct operator is needed afterwards.
assert(min <= max)

/*
This algorithm has been implemented using a state machine. This Cypher statement shows the static connections between the states.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really?

* @return the full expand depth
*/
def minOutgoingDepth(incomingRelId: Long): Int = {
var max = Constants.VERY_BIG_VALUE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this variable min instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using Integer.MAX_VALUE instead of this arbitrarily chosen VERY_BIG_VALUE?

This is the only place VERY_BIG_VALUE is used, so if that is changed, we no longer need to declare that constant - making the code easier to read (because a reader no longer needs to try to understand why the value is what it is).

@systay systay merged commit b923800 into neo4j:3.2 Mar 27, 2017
@fickludd fickludd deleted the 3.2-full-prune branch May 16, 2018 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants