A Performance Analysis of Different Types of Databases.Docx
Total Page:16
File Type:pdf, Size:1020Kb
nr ik v H e d a ap a l sk M a PERFORMANCE ANALYSIS OF RELATIONAL DATABASES, OBJECT-ORIENTED DATABASES AND ORM FRAMEWORKS PRESTANDAANALYS AV RELATIONSDATABASER, OBJEKTORIENTERADE DATABASER OCH ORM-RAMVERK Bachelor Degree Project in Computer Science 30 ECTS Spring term 2014 Victor Nagy Supervisor: Henrik Gustavsson Examiner: Göran Falkman Abstract In the planning stage of web and software development, it is important to select the right tool for the job. When selecting the database to use, relational databases like MySQL is a popular choice. However, relational databases suffer by object-relational impedance mismatch. In this work we will explore the response time of relational and object-oriented databases and the overhead of ORM frameworks. This will be done by creating a web application that receives data about flights and airports from a client, which measures the response time of the databases and the entire request. It was found that MySQL has the lowest response time, while the ORM framework Hibernate adds an overhead on some of the tests while performing similar to MySQL. Db4o had the highest response time in a majority of the tests. In future works, this study could be extended by other tests or by other type of databases. Keywords: database, relational database, object-oriented database, ORM framework, web Table of contents Table of contents................................................................................................................................................ 3 1 Introduction.....................................................................................................................................................1 2 Background..................................................................................................................................................... 2 2.1 Object-oriented programming and persistent data in web applications..............................................2 2.1.1 Java............................................................................................................................................2 2.2 Databases............................................................................................................................................. 2 2.2.1 Relational databases..................................................................................................................2 2.2.2 Object-oriented databases.........................................................................................................3 2.3 Object-Relational Mapping (ORM).....................................................................................................4 2.3.1 Hibernate...................................................................................................................................7 3 Problem........................................................................................................................................................... 8 3.1 Hypothesis............................................................................................................................................9 4 Method.......................................................................................................................................................... 10 4.1 Disadvantages with the method.........................................................................................................10 4.2 Evaluation.......................................................................................................................................... 11 4.3 Research ethics...................................................................................................................................11 5 Implementation...........................................................................................................................................13 5.1 Literature study.................................................................................................................................. 13 5.2 Frameworks, tools and libraries.........................................................................................................14 5.2.1 Play Framework......................................................................................................................14 5.2.2 MySQL................................................................................................................................... 15 5.2.3 Hibernate.................................................................................................................................17 5.2.4 db4o.........................................................................................................................................20 5.3 Development......................................................................................................................................21 5.3.1 Server...................................................................................................................................... 21 5.3.2 Client.......................................................................................................................................26 5.3.3 Client version 2.......................................................................................................................26 5.3.4 Conclusion.............................................................................................................................. 27 5.4 Pilot study.......................................................................................................................................... 27 5.4.1 Relational - Inserting airports.................................................................................................27 5.4.2 Relational - Inserting flights...................................................................................................28 5.4.3 Relational - Searching flights................................................................................................. 29 5.4.4 Relational - Listing all incoming flights to an airport............................................................30 6 Evaulation..................................................................................................................................................... 31 6.1 The Study........................................................................................................................................... 31 6.1.1 Summary.................................................................................................................................61 6.2 Analysis..............................................................................................................................................62 6.3 Conclusion......................................................................................................................................... 64 7 Concluding Remarks.....................................................................................................................................65 7.1 Summary............................................................................................................................................ 65 7.2 Discussion..........................................................................................................................................65 7.3 Future work........................................................................................................................................66 1 Introduction In many applications and websites there is a large need for persistence (Schahczenski, 2000). Persistence is the ability to save data between different executions of an application and between requests of a website. For example, a forum system needs to be able to save the posts the users make in case the information stored in memory is lost or the server is shut down (Kienzle and Romanovsky, 2002). A way to ensure data persistency for an application is to use database software to save data (Liu et al., 2008). Large websites and applications that need to do a lot of data operations rely on the overall system to keep working even under high load. One bottleneck for the application is the database overhead incurred when inserting and retrieving data. This is defined as server-side latency (Ghosh and Rau-Chaplin, 2006). On one hand one might need short response times when it comes from a database, on the other hand, there is development time and effort that might lead you to pick a database that is easier to develop code for. Relational databases are currently very popular (Bazghandi, 2006) but they are affected by the object-relational impedance mismatch (van Zyl et al., 2006). To solve that issue one could use an object-relational mapping (ORM) system or an object-oriented database. However, it might affect performance depending on the task. In this work we will compare the MySQL relational database to the db4o object-oriented database and the Hibernate ORM framework to evaluate the time taken to do inserts to the database and how long it takes to search the database. To do the comparison between the databases, a web application was developed. The web application uses the Play Java framework as a web framework and web server. The web application implements methods to insert and retrieve data from the MySQL relational database, from the db4o object database and to insert and retrieve data using the Hibernate