# Performance of Graph and Relational Databases in Complex Queries
## 8 Conclusions  
The present study compared relational database systems (MariaDB and two versions of MySQL) and a graph database system (Neo4j) efficiency using queries with different complexities. The results support earlier studies where graph database systems outperformed relational database systems with structurally simple datasets and simple queries. However, with more complex queries new relational database systems outperformed Neo4j.  
The significantly better performance of new relational database systems compared to MySQL 5.1 is not surprising as the tested MariaDB and MySQL 8.0.29 versions are 10 years newer, and many developments have occurred during that time. Although MariaDB is based on old MySQL, it offers a different feature set and is completely open source [25]. One significant change after MySQL 5.1.41 is a change in the default storage engine from MyISAM to InnoDB in version 5.5 [26]. InnoDB is used as a default storage engine of MariaDB. The study indicates the extent to which relational database query performance has improved during the last one and half decade.  
Neo4j outperformed modern relational database systems in most of the query tasks. Using the best settings of database systems, Neo4j was often at least three times faster than modern relational databases. However, in the task where an aggregated value was calculated for the given entity, Neo4J was 200 times faster than MySQL 8.0.29. In this task, the most essential difference between modern databases also appeared. MariaDB was over 90 times faster than MySQL 8.0.29. In the most complex query task, MariaDB was 29 times faster than Neo4j when indices were used and Neo4J query was optimized. In the same setting, MySQL 8.0.29 was 27 times faster than Neo4J. The role of optimization and indexing played an essential role in performance, especially in the long recursive query. Without indexing, basic Neo4J was the slowest, but the optimized query was the fastest. Indexing changes the situation, i.e., relational database systems outperformed Neo4J. MySQL 8.0.29 performed best. It was over 1000 times faster than the optimized Neo4J query and over 100,000 times faster than basic Neo4J.  
Our general conclusion is that on the basis of tests with our data set and queries, it cannot be generally concluded which of the database systems possesses the best query efficiency. In other words, the efficiency depends on the complexity of data and queries. Furthermore, query optimization and indexing may play important roles. This means that when choosing a database for an application domain, the query needs must be analyzed carefully beforehand. The results in the present study show how a relational database system is still a good alternative when it comes to performance compared with an NoSQL graph database.  
Conceptualization, P.K., M.J. and J.N.; Methodology, P.K., M.J. and J.N.; Software, P.K.; Validation, P.K., M.J. and J.N.; Formal Analysis, P.K., M.J. and J.N.; Investigation, P.K. and M.J.; Data Curation, P.K.; Writing--Original Draft Preparation, P.K., M.J. and J.N.; Writing--Review and Editing, P.K., M.J. and J.N.; Visualization, P.K. and M.J. All authors have read and agreed to the published version of the manuscript.  
This research received no external funding.  
Not applicable.  
The source code for generating the data is available in GitHub: [[https://github.com/homebeach/InvoicingDBTestBench](https://github.com/homebeach/InvoicingDBTestBench)]([https://github.com/homebeach/InvoicingDBTestBench](https://github.com/homebeach/InvoicingDBTestBench)) (accessed on 2 January 2022).  
The authors declare no conflict of interest.