RedisGraph

RedisGraph is a graph database built on Redis. It is a Redis module that extends the DBMS to provide graph database capabilities, including the property graph data model and graph query processing. RedisGraph exposes Cypher as its query language.

Graphs in RedisGraph are represented as sparse adjacency matrices. RedisGraph uses SuiteSparse, a package implemented GraphBLAS that provides a linear algebra interface for implementing graph algorithms, to represent sparse matrices and implement physical query operators, such as Conditional Traverse.

History

RedisGraph was created in 2018 by Roi Lipman from Redis Labs.

RedisGraph v.1.0 was released in November 2018. RedisGraph also released their benchmarking result on their system.

RedisGraph was also published as a short paper, RedisGraph GraphBLAS Enabled Graph Database (by Cailliau et al.), in IEEE IPDPS (GrAPL Workshop) in 2019.

RedisGraph v.2.0 was released in January 2020 with a full-text search, more Cypher language coverages, and performance improvement.

Checkpoints

Non-Blocking

RedisGraph does not provide additional checkpointing/snapshotting methods over the original Redis.

Compression

Null Suppression

Graphs in RedisGraph are stored in sparse representations supported by GraphBLAS.

According to GraphBLAS, it supports Compressed Sparse Row (CSR), Compressed Sparse Column (CSC), and Coordinate List (COO) to compress matrices. The key idea of all the sparse representations is to suppress zero/undefined values in matrices by storing only indices of non-zero elements.

Otherwise, there is no specific compression scheme for properties and attributes in RedisGraph.

Data Model

Graph

RedisGraph supports the property graph data model. Specifically, the data model defines nodes and edges. Nodes can have multiple labels, and edges can have a relationship type. Every node and edge can have multiple properties (i.e., attributes).

Foreign Keys

Not Supported

RedisGraph does not support any foreign key constraints.

Indexes

Patricia/Radix Trie

RedisGraph provides full-text indexes for querying nodes or edges by texts.

Specifically, RedisGraph uses RediSearch, which is an open-source Redis module. RediSearch uses Compact Prefix Tree (Radix Tree) and Trie (Prefix Tree) data structures.

Joins

Sort-Merge Join

RedisGraph provides a physical operator, Value Hash Join, which is used to join the records (i.e., tuples) from two child operators.

Although the name sounds like a hash join operator, the implementation is more similar to a sort-merge join. Their join operator starts with creating an array of the left operator's records. The array of the left operator's records will be sorted. The operator will iteratively probe the sorted array with the records from the right operator using a binary search algorithm.

Logging

Command Logging

RedisGraph does not implement any additional logging mechanism. Please refer to AOF, a Redis logging mechanism, in Redis instead.

Query Compilation

Not Supported

RedisGraph does not support query compilation.

Query Execution

Tuple-at-a-Time Model

RedisGraph uses the pull-based tuple-at-a-time query processing model to process queries.

When RedisGraph receives a query, RedisGraph will generate and then optimize a query plan according to the query. The query plan consists of physical query operators. All the query operators share the same interface, called Op. The tuple-at-a-time query processing engine will then process the query plan by calling the Consume function at the root of the query plan. The Consume function for every query operator commonly calls its children's Consume function recursively.

The implementations of graph-specific operators (such as Conditional Traverse) are mainly implemented with SuiteSparse, a linear algebra package for implementing graph algorithms conforming the GraphBLAS specification. The Conditional Traverse operator, which is used SuiteSparse, contains computing single-source breadth-first search (BFS) algorithm multiple times. The multiple-time single-source breadth-first search algorithm is implemented with a matrix-matrix multiplication in SuiteSparse.

The Conditional Traverse operator can form a matrix-matrix multiplication chain between adjacency matrices with different or the same relationship types if it needs to compute multiple-hop queries. Each matrix-matrix multiplication computes multiple-time single-source breadth-first search algorithms. Rather, the operator can use element-wise matrix multiplications to selectively choose only the frontier of the search that matches the node label depending on user queries.

Some operators allow a number of records to be batched before executing the operators' logic; for instance, the Conditional Traverse operator allows 16 (by default) records to be batched before calling a matrix-matrix multiplication.

Query Interface

Stored Procedures Cypher Command-line / Shell

RedisGraph exposes 9 commands:

  1. GRAPH.CONFIG stores/retrieves the current value of a RedisGraph configuration parameter.

  2. GRAPH.CONSTRAINT creates/drops graph constraints.

  3. GRAPH.DELETE deletes a graph specified.

  4. GRAPH.LIST lists all graphs managed by RedisGraph.

  5. GRAPH.EXPLAIN explains a query plan generated from a Cypher query.

  6. GRAPH.PROFILE profiles the time/records spent/produced by the query process of a Cypher query.

  7. GRAPH.QUERY executes a Cypher query.

  8. GRAPH.RO_QUERY executes a read-only Cypher query.

  9. GRAPH.SLOWLOG lists the 10 slowest queries of a specific graph.

The query must be specified in Cypher with limited coverage.

Users can use Redis client interfaces to interact with RedisGraph on Redis servers. Alternatively, users can use existing libraries to interact with RedisGraph. RedisGraph also exposes scripts for bulk inserting a graph.

Storage Architecture

In-Memory

RedisGraph utilizes Redis, which is in-memory. RedisGraph loads all graphs and their nodes/edges from persistent storage into memory before listening to clients.

Storage Model

Custom

RedisGraph stores a node or an edge by treating it as a document and putting it into Redis using RediSearch. The document is physically stored in Redis's managed hash tables. Different labels or relationship types create different indexes in RediSearch, which are Radix Tree (the rax implementation). Given a node has more than one label, the node is indexed across multiple indexes. The document treats properties in a node or an edge as fields.

Stored Procedures

Supported

RedisGraph allows users to provide their stored procedures written in C. Each stored procedure must be provided and registered before compiling the RedisGraph module. The registration must be currently done in this C file and must be exposed in this header file.

The valid stored procedure must contain a stored procedure name, a number of input arguments, an output specification (i.e., output data types, output field names), and three main routines. The three main routines include Invoke, Step, and Free.

  1. Invoke will be called first after the stored procedure is called.

  2. Step will be called multiple times to produce a result tuple per Step call.

  3. Free will be called to clean up allocated memory.

Users may store the state of each procedure call using the private_data pointer shared across these routines.

Views

Not Supported

RedisGraph does not support views.

Derivative Systems

People Also Viewed

RedisGraph Logo
Website

https://redisgraph.io/

Source Code

https://github.com/RedisGraph/RedisGraph

Tech Docs

https://redis.io/docs/stack/graph/

Twitter

@Redisinc

Developer

Redis Ltd.

Country of Origin

US

Start Year

2018

Project Type

Commercial, Open Source

Written in

C

Supported languages

C, C#, Elixir, Go, Java, JavaScript, Julia, PHP, Python, Ruby, Rust

Embeds / Uses

Redis

Operating Systems

Linux

Licenses

Server Side Public License

Derivative Systems

People Also Viewed