opencypher.org opencypher.org | opencypher@googlegroups.com - - PowerPoint PPT Presentation

opencypher org opencypher org opencypher googlegroups com
SMART_READER_LITE
LIVE PREVIEW

opencypher.org opencypher.org | opencypher@googlegroups.com - - PowerPoint PPT Presentation

opencypher.org opencypher.org | opencypher@googlegroups.com opencypher.org opencypher.org | opencypher@googlegroups.com START john=node:Person(name="John") MATCH john-[:KNOWS]-friend-[:KNOWS]-foaf RETURN


slide-1
SLIDE 1
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com
slide-2
SLIDE 2
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com
slide-3
SLIDE 3
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

START john=node:Person(name="John") MATCH john-[:KNOWS]-friend-[:KNOWS]-foaf RETURN foaf

slide-4
SLIDE 4
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

START john=node:Person(name="John") MATCH (john)-[:KNOWS]-(friend)-[:KNOWS]-(foaf) WHERE NOT (john)-[:KNOWS]-(foaf) AND NOT (john)-[:RECOMMENDATION]->(foaf) CREATE (john)-[:RECOMMENDATION]->(foaf) RETURN foaf

slide-5
SLIDE 5
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

MATCH (john:Person{name:"John"}), (john)-[:KNOWS]-(friend)-[:KNOWS]-(foaf) WHERE NOT (john)-[:KNOWS]-(foaf) MERGE (john)-[:RECOMMENDATION]->(foaf)

slide-6
SLIDE 6
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

Query => AST => AST’ AST’ => Query Graph => Logical Plan L Plan => Instruction => CodeGen => JVM Class

slide-7
SLIDE 7
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

(query:String)-[:PARSED_TO]->(:AST {pos: $pos})

slide-8
SLIDE 8
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

SemanticState => SemanticState

slide-9
SLIDE 9
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

The AST is optimised and canonicalized Custom functional rewriting code

slide-10
SLIDE 10
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com
slide-11
SLIDE 11
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

Output: Logical Plans similar to relational query plans Expand/VarExpand are the main differences to normal relational algebra

slide-12
SLIDE 12
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

Similar to the System R - Dynamic Programming Quick Reminder, the Selinger Algorithm: 1. Enumerate all access paths for single relation 2. Consider all ways to join two relations 3. Consider all ways to join three relations, etc

[Access path selection in a relational database management system, Selinger et al]

slide-13
SLIDE 13
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

Neo4j Cost Planner 1. Enumerate all access paths for pattern nodes 2. Consider all ways to expand pattern relationships 3. Consider all ways to solve two pattern relationships, either by expand or join, etc for three, four patter relationships

[Iterative dynamic programming: a new class of query optimization algorithms, Kossman, Stocker]

slide-14
SLIDE 14
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

Pattern: (a)-[r1]->(b)<-[r2]-(c) |a| e-[r1]-> (b) e-[r2]-> (c) ⋈ |a| |c| e-[r1]-> (b) e(b)<-[r2]- Solutions:

slide-15
SLIDE 15
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com
slide-16
SLIDE 16
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com
slide-17
SLIDE 17
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

IDPSolver SingleComponentPlanner CardinalityCostModel

slide-18
SLIDE 18
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com
  • accept(...)

L Plan => Instruction => CodeGen => JVM Class

[Efficiently Compiling Efficient Query Plans for Modern Hardware, Thomas Neumann]

slide-19
SLIDE 19
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

Cypher MATCH (n) WHERE n.x = 100 RETURN n Instruction

While(Variable("v1") -> ScanAllNodes()){ Selection( If("v1=100", AcceptVisitor( Map("n"-> NodeProjection(Variable("v1")))))) } )

slide-20
SLIDE 20
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

AllNodesScan Filter Project

slide-21
SLIDE 21
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com

AllNodesScan Filter Project

slide-22
SLIDE 22
  • pencypher.org
  • pencypher.org | opencypher@googlegroups.com