neo4j/neo4j — pull request #2030 by jexp (2014-02-21 21:14:34+00:00)
Title: rewrite: extract parameters from literals

This Pull Request adds functionality to cypher to automatically replace literals in statements with parameters. This enables reuse of already built query plans of the same structure that used other literal values in the same places.

After the rewriting the AST is equal to previously rewritten ASTs so the compiled query plan can be found in the plan-cache.

It uses the rewriting mechanisms in the compiler.

This mechanism saves up to 30% of execution time. Esp. in high load scenarios that currently use literals instead of parameters. Common use-cases are

1. Unoptimized applications with high numbers of the same literal cypher statements executed on behalf of web-application users
2. Massive import from different import sources that doesn't use parameters but generates cypher statements to create and update nodes and relationships.