SlideShare a Scribd company logo
© 2022 Neo4j, Inc. All rights reserved.
The Inside Scoop on Neo4j:
Meet the Builders
Stu Moore,
Product Manager for Neo4j Database
YOUR LOGO HERE
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
Inside Scoop on Neo4j
New ways to query the graph
• Node patterns [Gustav]
• Querying Fabric [Tobias]
Finding information faster
• Relationship indexes [Linnea]
Overcoming bottlenecks
• Relationship chain locks
[Valdemar]
2
Meet the Builders:
© 2022 Neo4j, Inc. All rights reserved.
3
New ways to query the graph
Gustav Hendergran
Core Database Engineer
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
4
Node pattern predicates
What is it?
- More advanced pattern matching
- A syntactic alternative for Cypher node patterns
Where is it used?
- MATCH and inside pattern comprehension
When to use it?
- As expressions become more complex
When can't you use it?
- MATCH (a:Person)-->(b:Person) WHERE a.age >
b.age
Improved
Node
Pattern
Matching
in Neo4j 4.4
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
5
Cypher in Neo4j 4.4
MATCH (n:Person WHERE n.age < 2)
RETURN n
MATCH (a:Person)-->(b:Person)
WHERE a.age > b.age
MATCH (n:Person)
WHERE n.age < 2
RETURN n
MATCH (a:Person)-->(b:Person)
WHERE a.age > b.age
Cypher before Neo4j 4.4
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> MATCH (p:Person)-->(m:Movie)
WHERE p.name STARTS WITH "Bill" AND m.released > 1995
RETURN p.name, m.title, m.released;
+-------------------------------------------------------+
| p.name | m.title | m.released |
+-------------------------------------------------------+
| "Billy Crystal" | "When Harry Met Sally" | 1998 |
| "Bill Paxton" | "Twister" | 1996 |
+-------------------------------------------------------+
6
Node pattern predicates in MATCH before Neo4j 4.4
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> MATCH (p:Person WHERE p.name STARTS WITH "Bill")-->
(m:Movie WHERE m.released > 1995)
RETURN p.name, m.title, m.released;
+-------------------------------------------------------+
| p.name | m.title | m.released |
+-------------------------------------------------------+
| "Billy Crystal" | "When Harry Met Sally" | 1998 |
| "Bill Paxton" | "Twister" | 1996 |
+-------------------------------------------------------+
7
Node pattern predicates in MATCH in Neo4j 4.4
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> MATCH (a:Person {name: 'Keanu Reeves'})
RETURN [(a)-->(b:Movie)<--(c:Person)
WHERE b.released > 1997
AND c.name CONTAINS "Nicholson" | b.title]
AS movies;
+----------------------------+
| movies |
+----------------------------+
| ["Something's Gotta Give"] |
+----------------------------+
8
Pattern comprehension before Neo4j 4.4
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> MATCH (a:Person {name: 'Keanu Reeves'})
RETURN [(a)-->(b:Movie WHERE b.released > 1997)<--
(c:Person WHERE c.name CONTAINS "Nicholson") | b.title]
AS movies;
+----------------------------+
| movies |
+----------------------------+
| ["Something's Gotta Give"] |
+----------------------------+
9
Pattern comprehension in Neo4j 4.4
© 2022 Neo4j, Inc. All rights reserved.
10
New ways to query the graph
with Fabric
Tobias Johansson
Core Database Engineer
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
11
Why Fabric? A way to…
Unlock more business value
• Query across multiple graphs -> FEDERATION
Operate at scale
• Virtually unlimited horizontal scale
• Increase performance w/ vertical scale
• Improved operations
◦ Manage smaller data sets
◦ Backup / restore
• SHARD TB data into 100s GB
Hybrid Cloud queries
• From Neo4j query across Aura & Neo4j*
What is it?
• Execute queries
in parallel across
databases
• Chain queries for
sophisticated
real-time analysis
• Query a
database
composed of
other databases
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
12
cards
shard01 shard02
"Fabric" Database
loans
shard03
Compose a graph from databases across clusters
Cluster01 Cluster02
© 2022 Neo4j, Inc. All rights reserved.
13
Fabric a social example
TBD: Set the scene for your social fabric example
Suggest a data model showing the people and the forums / posts and any info
you are going to show in the example etc
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
14
people posts1
social
posts2
Compose a graph from databases across clusters
cluster
Fabric
database
© 2022 Neo4j, Inc. All rights reserved.
neo4j@social> CALL {
USE social.people
MATCH (p:Person {id: 3})
RETURN p.id AS pid
}
CALL {
USE social.posts1
WITH pid
MATCH (p:Post {pid: pid})
RETURN p.title AS title
}
RETURN title;
15
Querying Fabric
Returns
+----------+
| title |
+----------+
| "Post 2" |
| "Post 3" |
+----------+
© 2022 Neo4j, Inc. All rights reserved.
neo4j@social> CALL {
USE social.people
MATCH (p:Person {id: 1})-
[:FOLLOWS]->(f)
RETURN f.id AS pid, f.name AS name
}
UNWIND social.graphIds() AS gid
CALL {
USE social.graph(gid)
WITH pid
MATCH (p:Post {pid: pid})
RETURN p.title AS title
}
RETURN gid, name, title;
16
Querying Fabric
Returns
+---------------------------+
| gid | name | title |
+---------------------------+
| 1 | "Daniel" | "Post 4" |
| 2 | "Daniel" | "Post 2" |
| 1 | "Daniel" | "Post 5" |
| 1 | "Daniel" | "Post 6" |
| 1 | "Cindy" | "Post 2" |
| 2 | "Cindy" | "Post 1" |
| 1 | "Cindy" | "Post 3" |
+---------------------------+
© 2022 Neo4j, Inc. All rights reserved.
neo4j@social> UNWIND social.graphIds() AS gid
CALL {
USE social.graph(gid)
MATCH (p:Post)
RETURN p.pid AS pid,
p.text AS text,
size(p.text) AS length
ORDER BY length DESC
LIMIT 1
}
RETURN *
ORDER BY length DESC
LIMIT 1;
17
Querying Fabric
Returns
+------------------------------
| gid | length | pid | text
+------------------------------
| 2 | 86 | 4 | "A great
+------------------------------
© 2022 Neo4j, Inc. All rights reserved.
18
Finding information faster
Linnéa Andersson,
Core Database Engineer
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
What it is
19
For Cypher users and Developers
looking for a significant performance
gain when using MATCH on
relationships by type and property
Similar to indexes for properties
associated to nodes, Neo4j 4.3+
provides native index capabilities for
properties associated to
relationships.
Relationship Type &
Property Indexes
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
What it is
20
For DBAs and architects who need to
optimize performance with indexes.
Neo4j 4.3 provided a new index for
node label and relationship types.
Created by default, when a database
is created with empty stores.
When stores are imported in a
database at creation, existing indexes
for labels and types are acquired,
administrators can modify them by
using CREATE/DROP INDEX commands.
Node Label &
Relationship Type lookup
indexes
© 2022 Neo4j, Inc. All rights reserved.
21
Goal: find all the twins in the
database (as quickly as possible)
Relationship type indexes
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> MATCH (me:Person)-[:TWIN_OF]->(twin:Person) RETURN *
+------------------------+-------------------------------+--------+
| Operator | Details | Rows |
+------------------------+-------------------------------+--------+
| +ProduceResults@neo4j | me, twin | 3981 |
| | +-------------------------------+--------+
| +Filter@neo4j | twin:Person | 3981 |
| | +-------------------------------+--------+
| +Expand(All)@neo4j | (me)-[anon_0:TWIN_OF]->(twin) | 3981 |
| | +-------------------------------+--------+
| +NodeByLabelScan@neo4j | me:Person | 204870 |
+------------------------+-------------------------------+--------+
22
To find all twins in a Neo4j 4.2 database
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> MATCH (me:Person)-[:TWIN_OF]->(twin:Person) RETURN *
+-------------------------------------+-------------------------------+------+
| Operator | Details | Rows |
+-------------------------------------+-------------------------------+------+
| +ProduceResults@neo4j | me, twin | 3981 |
| | +-------------------------------+------+
| +Filter@neo4j | me:Person AND twin:Person | 3981 |
| | +-------------------------------+------+
| +DirectedRelationshipTypeScan@neo4j | (me)-[anon_0:TWIN_OF]->(twin) | 3981 |
+-------------------------------------+-------------------------------+------+
23
To find all twins in a Neo4j 4.2 database
© 2022 Neo4j, Inc. All rights reserved.
24
Goal: find all parents on parental
leave in the database (as quickly
as possible)
Relationship property indexes
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> MATCH (parent:Person)-[r:PARENT_OF]->(child:Person)
WHERE r.on_parental_leave=true return *;
+------------------------+---------------------------------------------+--------+
| Operator | Details | Rows |
+------------------------+---------------------------------------------+--------+
| +ProduceResults@neo4j | parent, child | 84 |
| | +---------------------------------------------+--------+
| +Filter@neo4j | r.on_parental_leave = true AND child:Person | 84 |
| | +---------------------------------------------+--------+
| +Expand(All)@neo4j | (parent)-[r:PARENT_OF]->(child) | 102000 |
| | +---------------------------------------------+--------+
| +NodeByLabelScan@neo4j | parent:Person | 204872 |
+------------------------+---------------------------------------------+--------+
25
Goal find all parents on parental leave in Neo4j 4.2
© 2022 Neo4j, Inc. All rights reserved.
neo4j@neo4j> CREATE INDEX parental_leave IF NOT EXISTS FOR ()-[r:PARENT_OF]-()
ON ( r.on_parental_leave );
neo4j@neo4j> MATCH (parent:Person)-[r:PARENT_OF]->(child:Person)
WHERE r.on_parental_leave=true return *;
+-----------------------------+---------------------------------------------------------+-----+
| Operator | Details |Rows |
+-----------------------------+---------------------------------------------------------+-----+
| +ProduceResults@neo4j | parent, child | 84 |
| | +---------------------------------------------------------+-----+
| +Filter@neo4j | parent:Person AND child:Person | 84 |
| | +---------------------------------------------------------+-----+
| +DirectedRelationshipIndexS*| BTREE INDEX (parent)-[r:PARENT_OF(on_parental_leave)]-> | 84 |
| | (child) WHERE on_parental_leave = true | |
+-----------------------------+---------------------------------------------------------+-----+
*Abbreviated from DirectedRelationshipIndexScan@neo4j
26
Find all the parents on leave in Neo4j 4.3+
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
Relationship type/property planning
27
Relationship must
have type specified.
MATCH (me)-[knows:KNOWS]->(friend)-
[married:MARRIED_TO]->(friendSpouse)
:TYPE
MATCH (me)-[r]->(friend)-[m]->(friendSpouse)
The following wont work
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
WHERE knows.since IS NOT NULL
WHERE knows.since = 2010
WHERE knows.since IN [2010, 2020]
WHERE knows.since > 2010
WHERE 2000 < knows.since < 2010
WHERE married.witnessed_by STARTS WITH “Dr”
WHERE distance(knows.met_first, point({x:1,y:2})) < 2
Relationship type/property planning
28
• Composite
indexes are
supported.
• Can solve all
the same
predicates as
node indexes
WHERE married.witnessed_by ENDS WITH “Who”
WHERE married.witnessed_by CONTAINS “Who”
Following supported by "lucene+btree-3.0" index provider only
Follow with any one of the following WHERE statements
© 2022 Neo4j, Inc. All rights reserved.
29
Overcoming bottlenecks in the
model
How Neo4j solves for dense nodes, so you don't
have to redesign your model
© 2022 Neo4j, Inc. All rights reserved.
30
Dense node (un)locking
in Neo4j 4.3
Valdemar Roxling,
Core Database Engineer
© 2022 Neo4j, Inc. All rights reserved.
...
Bob
Bob
Bob
Bob
Bob
Dense nodes
Logical representation
GraphConnect Valdemar
SPEAKS_AT
Bob Bob
Bob
Bob
Bob
Bob
Alice
© 2022 Neo4j, Inc. All rights reserved.
...
Bob
Bob
Bob
Bob
Bob
Dense nodes
Logical representation
GraphConnect Valdemar
SPEAKS_AT
Bob Bob
Bob
Bob
Bob
Bob
Alice
Node store Relationship Group store Relationship store
Graph
Connect
SPEAKS_AT
ATTENDS_TO
R1
R2 R3 Rx
... Ry
Physical representation (seen from dense node)
© 2022 Neo4j, Inc. All rights reserved.
Locking problem
Relationships additions/removals prevents any other concurrent changes to either affected node
GraphConnect Bob
TX1
© 2022 Neo4j, Inc. All rights reserved.
Locking problem
Relationships additions/removals prevents any other concurrent changes to either affected node
GraphConnect Bob
TX1
Holds
© 2022 Neo4j, Inc. All rights reserved.
Locking problem
Relationships additions/removals prevents any other concurrent changes to either affected node
GraphConnect Bob
Alice
TX1
TX2
Holds
© 2022 Neo4j, Inc. All rights reserved.
Locking problem
Relationships additions/removals prevents any other concurrent changes to either affected node
GraphConnect Bob
Alice
TX1
TX2
Holds
© 2022 Neo4j, Inc. All rights reserved.
Granular locking
Only lock what is necessary to preserve data integrity
R1 R2 R3 R4 R5 R6 R7
© 2022 Neo4j, Inc. All rights reserved.
Granular locking
Only lock what is necessary to preserve data integrity
R1 R2 R3 R4 R5 R6 R7
TX1
© 2022 Neo4j, Inc. All rights reserved.
Granular locking
Only lock what is necessary to preserve data integrity
R1 R2 R3 R4 R5 R6 R7
TX1 TX2
© 2022 Neo4j, Inc. All rights reserved.
Granular locking
Only lock what is necessary to preserve data integrity
R1 R2 R3 R4
R1 R2 Rtx1 R3 R4
R5 R6 R7
TX1 TX2
R5 Rtx2 R6 R7
TX1
TX2
© 2022 Neo4j, Inc. All rights reserved.
© 2022 Neo4j, Inc. All rights reserved.
Concurrent modifications made total throughput
lower. Why?
41
© 2022 Neo4j, Inc. All rights reserved.
Deadlocks
More granular locks increases the risk of locks taken “out of order”
Transaction 1
Transaction 2
© 2022 Neo4j, Inc. All rights reserved.
Deadlocks
More granular locks increases the risk of locks taken “out of order”
Transaction 1
1
Transaction 2
© 2022 Neo4j, Inc. All rights reserved.
Deadlocks
More granular locks increases the risk of locks taken “out of order”
Transaction 1
1
Transaction 2
2
© 2022 Neo4j, Inc. All rights reserved.
Deadlocks
More granular locks increases the risk of locks taken “out of order”
Transaction 1
1 2
Transaction 2
2
Wait
for
© 2022 Neo4j, Inc. All rights reserved.
Deadlocks
More granular locks increases the risk of locks taken “out of order”
Transaction 1
1 2
Transaction 2
1
2
Wait
for
Deadlock!
© 2022 Neo4j, Inc. All rights reserved.
Sorting locks
Taking locks in specified order eliminates deadlocks
Transaction
db.beginTx()
© 2022 Neo4j, Inc. All rights reserved.
Sorting locks
Taking locks in specified order eliminates deadlocks
Transaction
db.beginTx()
denseNode.createRelationshipTo(node)
4
5
© 2022 Neo4j, Inc. All rights reserved.
Sorting locks
Taking locks in specified order eliminates deadlocks
Transaction
db.beginTx()
denseNode.createRelationshipTo(node)
denseNode.createRelationshipTo(otherNode)
4
5
2
© 2022 Neo4j, Inc. All rights reserved.
Sorting locks
Taking locks in specified order eliminates deadlocks
Transaction
db.beginTx()
denseNode.createRelationshipTo(node)
denseNode.createRelationshipTo(otherNode)
4
5
2
1
doWork()
3
© 2022 Neo4j, Inc. All rights reserved.
Sorting locks
Taking locks in specified order eliminates deadlocks
Transaction
db.beginTx()
tx.commit()
Commit
denseNode.createRelationshipTo(node)
denseNode.createRelationshipTo(otherNode)
1
2 3
4
5
doWork()
© 2022 Neo4j, Inc. All rights reserved.
Sorting locks
Taking locks in specified order eliminates deadlocks
Transaction
db.beginTx()
tx.commit()
Commit
denseNode.createRelationshipTo(node)
denseNode.createRelationshipTo(otherNode)
1
2
3
4
5
doWork()
© 2022 Neo4j, Inc. All rights reserved.
Summary
• Granular locking on dense nodes
◦ Allows concurrent additions/deletions
• Reworked locking scheme with sorted locks
◦ Greatly reduces risk of unexpected deadlocks
◦ Holds locks for a shorter duration
© 2022 Neo4j, Inc. All rights reserved.
54
Thank you!
Contact us at
sales@neo4j.com
YOUR LOGO HERE

More Related Content

PDF
Adobe Photoshop 2025 Free crack Download
alihamzakpa098
 
PDF
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
David Fombella Pombal
 
PPTX
Intro to Cypher
Brian Underwood
 
PDF
Neo4j: Graph-like power
Roman Rodomansky
 
PDF
Training Week: Introduction to Neo4j
Neo4j
 
PPTX
Top 10 Cypher Tuning Tips & Tricks
Neo4j
 
PPTX
GraphConnect 2022 - Top 10 Cypher Tuning Tips & Tricks.pptx
jexp
 
PDF
RadioBOSS Advanced 7.0.8 Free Download
blouch111kp
 
Adobe Photoshop 2025 Free crack Download
alihamzakpa098
 
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
David Fombella Pombal
 
Intro to Cypher
Brian Underwood
 
Neo4j: Graph-like power
Roman Rodomansky
 
Training Week: Introduction to Neo4j
Neo4j
 
Top 10 Cypher Tuning Tips & Tricks
Neo4j
 
GraphConnect 2022 - Top 10 Cypher Tuning Tips & Tricks.pptx
jexp
 
RadioBOSS Advanced 7.0.8 Free Download
blouch111kp
 

Similar to The Inside Scoop on Neo4j: Meet the Builders (20)

PDF
Office Tool Plus Free Download (Latest 2025)
blouch139kp
 
PDF
Evernote 10.132.4.49891 With Crack free
alihamzakpa080
 
PDF
Roadmap y Novedades de producto
Neo4j
 
PPT
Hands on Training – Graph Database with Neo4j
Serendio Inc.
 
PDF
managing big data
Suveeksha
 
PDF
Introduction to graph databases, Neo4j and Spring Data - English 2015 Edition
Aleksander Stensby
 
PDF
Neo4j (Part 1)
Bibhuti Regmi
 
PDF
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
Athens Big Data
 
PDF
03 introduction to graph databases
Neo4j
 
PDF
Training Series - Intro to Neo4j
Neo4j
 
PDF
Training Week: Introduction to Neo4j 2022
Neo4j
 
PDF
Introduction to Graph Databases with Neo4J
Brant Boehmann
 
PDF
Neo4j: The path to success with Graph Database and Graph Data Science
Neo4j
 
PDF
Workshop Introduction to Neo4j
Neo4j
 
PPT
Neo4 j
Dr.Saranya K.G
 
PDF
Graph Database Using Neo4J
Harmeet Singh(Taara)
 
PDF
Neo4J
nklmish
 
PDF
Data modeling with neo4j tutorial
Max De Marzi
 
PDF
Understanding Graph Databases with Neo4j and Cypher
Ruhaim Izmeth
 
Office Tool Plus Free Download (Latest 2025)
blouch139kp
 
Evernote 10.132.4.49891 With Crack free
alihamzakpa080
 
Roadmap y Novedades de producto
Neo4j
 
Hands on Training – Graph Database with Neo4j
Serendio Inc.
 
managing big data
Suveeksha
 
Introduction to graph databases, Neo4j and Spring Data - English 2015 Edition
Aleksander Stensby
 
Neo4j (Part 1)
Bibhuti Regmi
 
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
Athens Big Data
 
03 introduction to graph databases
Neo4j
 
Training Series - Intro to Neo4j
Neo4j
 
Training Week: Introduction to Neo4j 2022
Neo4j
 
Introduction to Graph Databases with Neo4J
Brant Boehmann
 
Neo4j: The path to success with Graph Database and Graph Data Science
Neo4j
 
Workshop Introduction to Neo4j
Neo4j
 
Graph Database Using Neo4J
Harmeet Singh(Taara)
 
Neo4J
nklmish
 
Data modeling with neo4j tutorial
Max De Marzi
 
Understanding Graph Databases with Neo4j and Cypher
Ruhaim Izmeth
 
Ad

More from Neo4j (20)

PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Jin Foo - Prospa GraphSummit Sydney Presentation.pdf
Neo4j
 
PDF
GraphSummit Singapore Master Deck - May 20, 2025
Neo4j
 
PPTX
Graphs & GraphRAG - Essential Ingredients for GenAI
Neo4j
 
PPTX
Neo4j Knowledge for Customer Experience.pptx
Neo4j
 
PPTX
GraphTalk New Zealand - The Art of The Possible.pptx
Neo4j
 
PDF
Neo4j: The Art of the Possible with Graph
Neo4j
 
PDF
Smarter Knowledge Graphs For Public Sector
Neo4j
 
PDF
GraphRAG and Knowledge Graphs Exploring AI's Future
Neo4j
 
PDF
Matinée GenAI & GraphRAG Paris - Décembre 24
Neo4j
 
PDF
ANZ Presentation: GraphSummit Melbourne 2024
Neo4j
 
PDF
Google Cloud Presentation GraphSummit Melbourne 2024: Building Generative AI ...
Neo4j
 
PDF
Telstra Presentation GraphSummit Melbourne: Optimising Business Outcomes with...
Neo4j
 
PDF
Hands-On GraphRAG Workshop: GraphSummit Melbourne 2024
Neo4j
 
PDF
Démonstration Digital Twin Building Wire Management
Neo4j
 
PDF
Swiss Life - Les graphes au service de la détection de fraude dans le domaine...
Neo4j
 
PDF
Démonstration Supply Chain - GraphTalk Paris
Neo4j
 
PDF
The Art of Possible - GraphTalk Paris Opening Session
Neo4j
 
PPTX
How Siemens bolstered supply chain resilience with graph-powered AI insights ...
Neo4j
 
PDF
Knowledge Graphs for AI-Ready Data and Enterprise Deployment - Gartner IT Sym...
Neo4j
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Jin Foo - Prospa GraphSummit Sydney Presentation.pdf
Neo4j
 
GraphSummit Singapore Master Deck - May 20, 2025
Neo4j
 
Graphs & GraphRAG - Essential Ingredients for GenAI
Neo4j
 
Neo4j Knowledge for Customer Experience.pptx
Neo4j
 
GraphTalk New Zealand - The Art of The Possible.pptx
Neo4j
 
Neo4j: The Art of the Possible with Graph
Neo4j
 
Smarter Knowledge Graphs For Public Sector
Neo4j
 
GraphRAG and Knowledge Graphs Exploring AI's Future
Neo4j
 
Matinée GenAI & GraphRAG Paris - Décembre 24
Neo4j
 
ANZ Presentation: GraphSummit Melbourne 2024
Neo4j
 
Google Cloud Presentation GraphSummit Melbourne 2024: Building Generative AI ...
Neo4j
 
Telstra Presentation GraphSummit Melbourne: Optimising Business Outcomes with...
Neo4j
 
Hands-On GraphRAG Workshop: GraphSummit Melbourne 2024
Neo4j
 
Démonstration Digital Twin Building Wire Management
Neo4j
 
Swiss Life - Les graphes au service de la détection de fraude dans le domaine...
Neo4j
 
Démonstration Supply Chain - GraphTalk Paris
Neo4j
 
The Art of Possible - GraphTalk Paris Opening Session
Neo4j
 
How Siemens bolstered supply chain resilience with graph-powered AI insights ...
Neo4j
 
Knowledge Graphs for AI-Ready Data and Enterprise Deployment - Gartner IT Sym...
Neo4j
 
Ad

Recently uploaded (20)

PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 

The Inside Scoop on Neo4j: Meet the Builders

  • 1. © 2022 Neo4j, Inc. All rights reserved. The Inside Scoop on Neo4j: Meet the Builders Stu Moore, Product Manager for Neo4j Database YOUR LOGO HERE
  • 2. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. Inside Scoop on Neo4j New ways to query the graph • Node patterns [Gustav] • Querying Fabric [Tobias] Finding information faster • Relationship indexes [Linnea] Overcoming bottlenecks • Relationship chain locks [Valdemar] 2 Meet the Builders:
  • 3. © 2022 Neo4j, Inc. All rights reserved. 3 New ways to query the graph Gustav Hendergran Core Database Engineer
  • 4. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. 4 Node pattern predicates What is it? - More advanced pattern matching - A syntactic alternative for Cypher node patterns Where is it used? - MATCH and inside pattern comprehension When to use it? - As expressions become more complex When can't you use it? - MATCH (a:Person)-->(b:Person) WHERE a.age > b.age Improved Node Pattern Matching in Neo4j 4.4
  • 5. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. 5 Cypher in Neo4j 4.4 MATCH (n:Person WHERE n.age < 2) RETURN n MATCH (a:Person)-->(b:Person) WHERE a.age > b.age MATCH (n:Person) WHERE n.age < 2 RETURN n MATCH (a:Person)-->(b:Person) WHERE a.age > b.age Cypher before Neo4j 4.4
  • 6. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> MATCH (p:Person)-->(m:Movie) WHERE p.name STARTS WITH "Bill" AND m.released > 1995 RETURN p.name, m.title, m.released; +-------------------------------------------------------+ | p.name | m.title | m.released | +-------------------------------------------------------+ | "Billy Crystal" | "When Harry Met Sally" | 1998 | | "Bill Paxton" | "Twister" | 1996 | +-------------------------------------------------------+ 6 Node pattern predicates in MATCH before Neo4j 4.4
  • 7. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> MATCH (p:Person WHERE p.name STARTS WITH "Bill")--> (m:Movie WHERE m.released > 1995) RETURN p.name, m.title, m.released; +-------------------------------------------------------+ | p.name | m.title | m.released | +-------------------------------------------------------+ | "Billy Crystal" | "When Harry Met Sally" | 1998 | | "Bill Paxton" | "Twister" | 1996 | +-------------------------------------------------------+ 7 Node pattern predicates in MATCH in Neo4j 4.4
  • 8. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> MATCH (a:Person {name: 'Keanu Reeves'}) RETURN [(a)-->(b:Movie)<--(c:Person) WHERE b.released > 1997 AND c.name CONTAINS "Nicholson" | b.title] AS movies; +----------------------------+ | movies | +----------------------------+ | ["Something's Gotta Give"] | +----------------------------+ 8 Pattern comprehension before Neo4j 4.4
  • 9. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> MATCH (a:Person {name: 'Keanu Reeves'}) RETURN [(a)-->(b:Movie WHERE b.released > 1997)<-- (c:Person WHERE c.name CONTAINS "Nicholson") | b.title] AS movies; +----------------------------+ | movies | +----------------------------+ | ["Something's Gotta Give"] | +----------------------------+ 9 Pattern comprehension in Neo4j 4.4
  • 10. © 2022 Neo4j, Inc. All rights reserved. 10 New ways to query the graph with Fabric Tobias Johansson Core Database Engineer
  • 11. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. 11 Why Fabric? A way to… Unlock more business value • Query across multiple graphs -> FEDERATION Operate at scale • Virtually unlimited horizontal scale • Increase performance w/ vertical scale • Improved operations ◦ Manage smaller data sets ◦ Backup / restore • SHARD TB data into 100s GB Hybrid Cloud queries • From Neo4j query across Aura & Neo4j* What is it? • Execute queries in parallel across databases • Chain queries for sophisticated real-time analysis • Query a database composed of other databases
  • 12. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. 12 cards shard01 shard02 "Fabric" Database loans shard03 Compose a graph from databases across clusters Cluster01 Cluster02
  • 13. © 2022 Neo4j, Inc. All rights reserved. 13 Fabric a social example TBD: Set the scene for your social fabric example Suggest a data model showing the people and the forums / posts and any info you are going to show in the example etc
  • 14. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. 14 people posts1 social posts2 Compose a graph from databases across clusters cluster Fabric database
  • 15. © 2022 Neo4j, Inc. All rights reserved. neo4j@social> CALL { USE social.people MATCH (p:Person {id: 3}) RETURN p.id AS pid } CALL { USE social.posts1 WITH pid MATCH (p:Post {pid: pid}) RETURN p.title AS title } RETURN title; 15 Querying Fabric Returns +----------+ | title | +----------+ | "Post 2" | | "Post 3" | +----------+
  • 16. © 2022 Neo4j, Inc. All rights reserved. neo4j@social> CALL { USE social.people MATCH (p:Person {id: 1})- [:FOLLOWS]->(f) RETURN f.id AS pid, f.name AS name } UNWIND social.graphIds() AS gid CALL { USE social.graph(gid) WITH pid MATCH (p:Post {pid: pid}) RETURN p.title AS title } RETURN gid, name, title; 16 Querying Fabric Returns +---------------------------+ | gid | name | title | +---------------------------+ | 1 | "Daniel" | "Post 4" | | 2 | "Daniel" | "Post 2" | | 1 | "Daniel" | "Post 5" | | 1 | "Daniel" | "Post 6" | | 1 | "Cindy" | "Post 2" | | 2 | "Cindy" | "Post 1" | | 1 | "Cindy" | "Post 3" | +---------------------------+
  • 17. © 2022 Neo4j, Inc. All rights reserved. neo4j@social> UNWIND social.graphIds() AS gid CALL { USE social.graph(gid) MATCH (p:Post) RETURN p.pid AS pid, p.text AS text, size(p.text) AS length ORDER BY length DESC LIMIT 1 } RETURN * ORDER BY length DESC LIMIT 1; 17 Querying Fabric Returns +------------------------------ | gid | length | pid | text +------------------------------ | 2 | 86 | 4 | "A great +------------------------------
  • 18. © 2022 Neo4j, Inc. All rights reserved. 18 Finding information faster Linnéa Andersson, Core Database Engineer
  • 19. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. What it is 19 For Cypher users and Developers looking for a significant performance gain when using MATCH on relationships by type and property Similar to indexes for properties associated to nodes, Neo4j 4.3+ provides native index capabilities for properties associated to relationships. Relationship Type & Property Indexes
  • 20. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. What it is 20 For DBAs and architects who need to optimize performance with indexes. Neo4j 4.3 provided a new index for node label and relationship types. Created by default, when a database is created with empty stores. When stores are imported in a database at creation, existing indexes for labels and types are acquired, administrators can modify them by using CREATE/DROP INDEX commands. Node Label & Relationship Type lookup indexes
  • 21. © 2022 Neo4j, Inc. All rights reserved. 21 Goal: find all the twins in the database (as quickly as possible) Relationship type indexes
  • 22. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> MATCH (me:Person)-[:TWIN_OF]->(twin:Person) RETURN * +------------------------+-------------------------------+--------+ | Operator | Details | Rows | +------------------------+-------------------------------+--------+ | +ProduceResults@neo4j | me, twin | 3981 | | | +-------------------------------+--------+ | +Filter@neo4j | twin:Person | 3981 | | | +-------------------------------+--------+ | +Expand(All)@neo4j | (me)-[anon_0:TWIN_OF]->(twin) | 3981 | | | +-------------------------------+--------+ | +NodeByLabelScan@neo4j | me:Person | 204870 | +------------------------+-------------------------------+--------+ 22 To find all twins in a Neo4j 4.2 database
  • 23. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> MATCH (me:Person)-[:TWIN_OF]->(twin:Person) RETURN * +-------------------------------------+-------------------------------+------+ | Operator | Details | Rows | +-------------------------------------+-------------------------------+------+ | +ProduceResults@neo4j | me, twin | 3981 | | | +-------------------------------+------+ | +Filter@neo4j | me:Person AND twin:Person | 3981 | | | +-------------------------------+------+ | +DirectedRelationshipTypeScan@neo4j | (me)-[anon_0:TWIN_OF]->(twin) | 3981 | +-------------------------------------+-------------------------------+------+ 23 To find all twins in a Neo4j 4.2 database
  • 24. © 2022 Neo4j, Inc. All rights reserved. 24 Goal: find all parents on parental leave in the database (as quickly as possible) Relationship property indexes
  • 25. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> MATCH (parent:Person)-[r:PARENT_OF]->(child:Person) WHERE r.on_parental_leave=true return *; +------------------------+---------------------------------------------+--------+ | Operator | Details | Rows | +------------------------+---------------------------------------------+--------+ | +ProduceResults@neo4j | parent, child | 84 | | | +---------------------------------------------+--------+ | +Filter@neo4j | r.on_parental_leave = true AND child:Person | 84 | | | +---------------------------------------------+--------+ | +Expand(All)@neo4j | (parent)-[r:PARENT_OF]->(child) | 102000 | | | +---------------------------------------------+--------+ | +NodeByLabelScan@neo4j | parent:Person | 204872 | +------------------------+---------------------------------------------+--------+ 25 Goal find all parents on parental leave in Neo4j 4.2
  • 26. © 2022 Neo4j, Inc. All rights reserved. neo4j@neo4j> CREATE INDEX parental_leave IF NOT EXISTS FOR ()-[r:PARENT_OF]-() ON ( r.on_parental_leave ); neo4j@neo4j> MATCH (parent:Person)-[r:PARENT_OF]->(child:Person) WHERE r.on_parental_leave=true return *; +-----------------------------+---------------------------------------------------------+-----+ | Operator | Details |Rows | +-----------------------------+---------------------------------------------------------+-----+ | +ProduceResults@neo4j | parent, child | 84 | | | +---------------------------------------------------------+-----+ | +Filter@neo4j | parent:Person AND child:Person | 84 | | | +---------------------------------------------------------+-----+ | +DirectedRelationshipIndexS*| BTREE INDEX (parent)-[r:PARENT_OF(on_parental_leave)]-> | 84 | | | (child) WHERE on_parental_leave = true | | +-----------------------------+---------------------------------------------------------+-----+ *Abbreviated from DirectedRelationshipIndexScan@neo4j 26 Find all the parents on leave in Neo4j 4.3+
  • 27. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. Relationship type/property planning 27 Relationship must have type specified. MATCH (me)-[knows:KNOWS]->(friend)- [married:MARRIED_TO]->(friendSpouse) :TYPE MATCH (me)-[r]->(friend)-[m]->(friendSpouse) The following wont work
  • 28. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. WHERE knows.since IS NOT NULL WHERE knows.since = 2010 WHERE knows.since IN [2010, 2020] WHERE knows.since > 2010 WHERE 2000 < knows.since < 2010 WHERE married.witnessed_by STARTS WITH “Dr” WHERE distance(knows.met_first, point({x:1,y:2})) < 2 Relationship type/property planning 28 • Composite indexes are supported. • Can solve all the same predicates as node indexes WHERE married.witnessed_by ENDS WITH “Who” WHERE married.witnessed_by CONTAINS “Who” Following supported by "lucene+btree-3.0" index provider only Follow with any one of the following WHERE statements
  • 29. © 2022 Neo4j, Inc. All rights reserved. 29 Overcoming bottlenecks in the model How Neo4j solves for dense nodes, so you don't have to redesign your model
  • 30. © 2022 Neo4j, Inc. All rights reserved. 30 Dense node (un)locking in Neo4j 4.3 Valdemar Roxling, Core Database Engineer
  • 31. © 2022 Neo4j, Inc. All rights reserved. ... Bob Bob Bob Bob Bob Dense nodes Logical representation GraphConnect Valdemar SPEAKS_AT Bob Bob Bob Bob Bob Bob Alice
  • 32. © 2022 Neo4j, Inc. All rights reserved. ... Bob Bob Bob Bob Bob Dense nodes Logical representation GraphConnect Valdemar SPEAKS_AT Bob Bob Bob Bob Bob Bob Alice Node store Relationship Group store Relationship store Graph Connect SPEAKS_AT ATTENDS_TO R1 R2 R3 Rx ... Ry Physical representation (seen from dense node)
  • 33. © 2022 Neo4j, Inc. All rights reserved. Locking problem Relationships additions/removals prevents any other concurrent changes to either affected node GraphConnect Bob TX1
  • 34. © 2022 Neo4j, Inc. All rights reserved. Locking problem Relationships additions/removals prevents any other concurrent changes to either affected node GraphConnect Bob TX1 Holds
  • 35. © 2022 Neo4j, Inc. All rights reserved. Locking problem Relationships additions/removals prevents any other concurrent changes to either affected node GraphConnect Bob Alice TX1 TX2 Holds
  • 36. © 2022 Neo4j, Inc. All rights reserved. Locking problem Relationships additions/removals prevents any other concurrent changes to either affected node GraphConnect Bob Alice TX1 TX2 Holds
  • 37. © 2022 Neo4j, Inc. All rights reserved. Granular locking Only lock what is necessary to preserve data integrity R1 R2 R3 R4 R5 R6 R7
  • 38. © 2022 Neo4j, Inc. All rights reserved. Granular locking Only lock what is necessary to preserve data integrity R1 R2 R3 R4 R5 R6 R7 TX1
  • 39. © 2022 Neo4j, Inc. All rights reserved. Granular locking Only lock what is necessary to preserve data integrity R1 R2 R3 R4 R5 R6 R7 TX1 TX2
  • 40. © 2022 Neo4j, Inc. All rights reserved. Granular locking Only lock what is necessary to preserve data integrity R1 R2 R3 R4 R1 R2 Rtx1 R3 R4 R5 R6 R7 TX1 TX2 R5 Rtx2 R6 R7 TX1 TX2
  • 41. © 2022 Neo4j, Inc. All rights reserved. © 2022 Neo4j, Inc. All rights reserved. Concurrent modifications made total throughput lower. Why? 41
  • 42. © 2022 Neo4j, Inc. All rights reserved. Deadlocks More granular locks increases the risk of locks taken “out of order” Transaction 1 Transaction 2
  • 43. © 2022 Neo4j, Inc. All rights reserved. Deadlocks More granular locks increases the risk of locks taken “out of order” Transaction 1 1 Transaction 2
  • 44. © 2022 Neo4j, Inc. All rights reserved. Deadlocks More granular locks increases the risk of locks taken “out of order” Transaction 1 1 Transaction 2 2
  • 45. © 2022 Neo4j, Inc. All rights reserved. Deadlocks More granular locks increases the risk of locks taken “out of order” Transaction 1 1 2 Transaction 2 2 Wait for
  • 46. © 2022 Neo4j, Inc. All rights reserved. Deadlocks More granular locks increases the risk of locks taken “out of order” Transaction 1 1 2 Transaction 2 1 2 Wait for Deadlock!
  • 47. © 2022 Neo4j, Inc. All rights reserved. Sorting locks Taking locks in specified order eliminates deadlocks Transaction db.beginTx()
  • 48. © 2022 Neo4j, Inc. All rights reserved. Sorting locks Taking locks in specified order eliminates deadlocks Transaction db.beginTx() denseNode.createRelationshipTo(node) 4 5
  • 49. © 2022 Neo4j, Inc. All rights reserved. Sorting locks Taking locks in specified order eliminates deadlocks Transaction db.beginTx() denseNode.createRelationshipTo(node) denseNode.createRelationshipTo(otherNode) 4 5 2
  • 50. © 2022 Neo4j, Inc. All rights reserved. Sorting locks Taking locks in specified order eliminates deadlocks Transaction db.beginTx() denseNode.createRelationshipTo(node) denseNode.createRelationshipTo(otherNode) 4 5 2 1 doWork() 3
  • 51. © 2022 Neo4j, Inc. All rights reserved. Sorting locks Taking locks in specified order eliminates deadlocks Transaction db.beginTx() tx.commit() Commit denseNode.createRelationshipTo(node) denseNode.createRelationshipTo(otherNode) 1 2 3 4 5 doWork()
  • 52. © 2022 Neo4j, Inc. All rights reserved. Sorting locks Taking locks in specified order eliminates deadlocks Transaction db.beginTx() tx.commit() Commit denseNode.createRelationshipTo(node) denseNode.createRelationshipTo(otherNode) 1 2 3 4 5 doWork()
  • 53. © 2022 Neo4j, Inc. All rights reserved. Summary • Granular locking on dense nodes ◦ Allows concurrent additions/deletions • Reworked locking scheme with sorted locks ◦ Greatly reduces risk of unexpected deadlocks ◦ Holds locks for a shorter duration
  • 54. © 2022 Neo4j, Inc. All rights reserved. 54 Thank you! Contact us at [email protected] YOUR LOGO HERE

Editor's Notes

  • #3: Node patterns with predicates on properties How to query a graph that is federated or composed of shards Relationship type & property indexes
  • #5: new (variables in previous MATCH can be used) Tease quantified path patterns in 5.0? Yes we can allude to general improvements
  • #12: Stu present But not visa versa - you cant query from Aura to self-managed using Fabric
  • #13: Stu present
  • #14: Tobias present
  • #21: 4.2: NodeLabelScanStore 4.3 lookup indexes for node labels and relationship types. The node label lookup index is very similar to the nodeLabelScanStore, whereas the relationship type lookup index is new. The indexes are created by default (when a database is created with empty stores). If stores are imported on database creation, the node label lookup index will be created (since it was there in previous versions but as label scan store). However, no relationship type index will be created, since there was no such index in 4.2. It is possible to create/drop indexes using cypher commands - you can find out how in the cypher documentation.
  • #28: *
  • #29: *