https://github.com/famousdraw

Neo4j Fundamentals-Native Graph Advantage

VIDEO

Native Graph Advantage

VideoTranscript
 

Neo4j is a native graph database

Neo4j is a native graph database, meaning that everything from the storage of the data to the query language have been designed specifically with traversal in mind.

Where native graph databases stand apart from other databases is the concept of index-free adjacency. When a database transaction is committed, a reference to the relationship is stored with the nodes at both the start and end of the relationship. As each node is aware of every incoming and outgoing relationship connected to it, the underlying graph engine will simply chase pointers in memory - something that computers are exceptionally good at.

Index-free adjacency (IFA)

One of the key features that makes Neo4j graph databases different from an RDBMS is that Neo4j implements index-free adjacency.

RDBMS query

RelationalTable1

To better understand the benefit of index-free adjacency, let’s look at how a query executes in an RDBMS.

Suppose you have this table in the RDBMS.

You execute this SQL query to find the third-degree parents of the group with the ID of 3:

SQL
 
SELECT PARENT_ID
FROM GROUPS
WHERE ID = (SELECT PARENT_ID
    FROM GROUPS
    WHERE ID = (SELECT PARENT_ID
        FROM GROUPS
        WHERE ID = 3))

The result of this query is 1, but in order to determine this result, the SQL Server needed to:

  1. Locate the innermost clause.

  2. Build the query plan for the subclause.

  3. Execute the query plan for the subclause.

  4. Locate the next innermost clause.

  5. Repeat Steps 2-4.

Resulting in:

  • 3 planning cycles

  • 3 index lookups

  • 3 DB reads

Neo4j storage

With index-free adjacency, Neo4j stores nodes and relationships as objects that are linked to each other via pointers. Conceptually, the graph looks like:

IFA-1-new

These nodes and relationships are stored as:

IFA-2-new

Neo4j Cypher query

Suppose we had this query in Cypher:

Cypher
 
MATCH (n) <-- (:Group) <-- (:Group) <-- (:Group {id: 3})
RETURN n.id

Using IFA, the Neo4j graph engine starts with the anchor of the query which is the Group node with the id of 3. Then it uses the links stored in the relationship and node objects to traverse the graph pattern.

IFA-3-new

To perform this query, the Neo4j graph engine needed to:

  1. Plan the query based upon the anchor specified.

  2. Use an index to retrieve the anchor node.

  3. Follow pointers to retrieve the desired result node.

The benefits of IFA compared to relational DBMS access are:

  • Fewer index lookups.

  • No table scans.

  • Reduced duplication of data.

Check your understanding

1. Index-free adjacency

What are the key benefits of Neo4j’s index-free adjacency?

  • Foreign keys are built into each node.

  • Fewer index lookups.

  • No table scans.

  • Reduced duplication of data.

posted on   红色MINI  阅读(60)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示