OQGRAPH Engine for MariaDB

6n-graphThe Open Query GRAPH engine (OQGRAPH) is a computation engine allowing hierarchies and more complex graph structures to be handled in a relational fashion. In a nutshell, tree structures and friend-of-a-friend style searches can now be done using standard SQL syntax, and results joined onto other tables.

No server modifications or SQL syntax extensions are necessary, the engine is implemented as a clean engine plugin for MariaDB 5.2 and above, this means that the OQGRAPH plugin (distributed with MariaDB) gets loaded at runtime.

See the OQGRAPH Documentation for more information, downloads, examples, etc. General information below.


The Open Query GRAPH computation engine, or OQGRAPH as the engine itself is called, allows you to handle hierarchies (tree structures) but also complex graphs (nodes having many connections in several directions). Have you wrestled with the adjacency model, nested sets or materialised paths, or wondered how the blazes to do friend-of-a-friend style searches in your SQL relational database, result required today please? That’s right, you and everybody else!

I encountered the same problem years ago when building web applications. An RDBMS “thinks” in sets, and sets just don’t lend themselves well to dealing with these structures, and then SQL is no help either. But understanding how MySQL works, plus a bit of background in electronics, enabled me to come up with a solution.

Other database servers have syntax like CONNECT BY PRIOR (Oracle) and the SQL-99 standard introduces something called a “recursive union”. Look, these features are functional and do what they do, but a) they’re limited b) not that easy to use c) not fast and d) not available in MySQL. I realise I’m setting the bar very high by making statements on ease of use and speed, but we now have a functional “competitor” to back all of this, and more: OQGRAPH is accessed through simple single queries in standard SQL, you can use it in joins or any other supported construct, and it can handle any graph structure without breaking a sweat.

So in a nutshell, you can make your existing tree operations more convenient, but it’s also enabling technology in the sense that you can now do things that simply weren’t possible (inside  an SQL RDBMS) before.

But it’s a Storage Engine, right?

Yes and no. Don’t you hate answers like that? But it’s the truth.

In the MySQL/MariaDB server infrastructure, OQGRAPH is a storage engine, just like InnoDB. But even though it superficially looks like an engine and it’s the server API we use, it’s actually an altogether different product: it’s a computation engine. On the inside it’s a native graph, there are no rows, and some of the columns you see on the outside don’t exist. And there is definitely no table.

Confused yet? No worries, OQGRAPH is really easy to use (and that’s not just geek talk), but it’s essential that you don’t think of it as a regular storage engine. For instance, it’s downright impossible to store regular data in it.


antony-arjen-mysqlconf2008The OQGRAPH engine is based on an original idea by Open Query founder Arjen Lentz, and has been developed in-house with Antony Curtis who is a veteran in MySQL server code and storage engines. Lots work has since been done by Andrew McDonnell, and now users and other third parties are also contributing fixes and new features.

From the earlier proof of concept we had valuable support from MySQL and MariaDB core developers such as Sergei Golubchik, Timour Katchaounov, and Igor Babaev.

Availability & Licensing

The v3 implementation is available as a gift to you, under the GPLv2+ license (please contact us if you have special licensing requirements).

I want it!

Sure! You can grab MariaDB 5.2 or higher at mariadb.org, and you can find the source in the oqgraph storage engine plugin directory of the mariadb tree on Launchpad. The oqgraph project on Launchpad tracks the historical implementation for MySQL 5.0, and was used for the newer persistent v3 (in MariaDB 10.0 and above).

Support & Engineering

You can contact us if you have any questions.