Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

2022 - Performance analysis of relational databases MySQL, PostgreSQL and

Uploaded by

胡仲义
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

2022 - Performance analysis of relational databases MySQL, PostgreSQL and

Uploaded by

胡仲义
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

JCSI 24 (2022) 250–257

Received: 14 June 2022


Accepted: 6 July 2022

Performance analysis of relational databases MySQL, PostgreSQL and


Oracle using Doctrine libraries
Analiza wydajności relacyjnych baz danych MySQL, PostgreSQL oraz
Oracle z zastosowaniem bibliotek Doctrine
Marcin Choina* , M. Skublewska-Paszkowska
Department of Computer Science, Lublin University of Technology, Nadbystrzycka 36B, 20-618 Lublin, Poland
Abstract
In modern applications, databases perform a very important function but the choice of a database system and additional
libraries may affect the speed of the operations. The paper presents a time analysis concerning the performing of insert,
update, delete and select operations on three database systems, MySQL 8.0, PostgreSQL 14.1 and Oracle 21c, cooperat-
ing with an application using Doctrine libraries. The obtained results showed differences between performing opera-
tions with and without object-relational mapping. In cooperation with the application, the operations were carried out
the fastest using the PostgreSQL system. The Oracle system performed data selection faster without mapping on a large
data set.
Keywords: relational databases; Doctrine; ORM; PHP
Streszczenie
We współczesnych aplikacjach, bazy danych pełnią bardzo ważną rolę, jednak wybór systemu bazodanowego i dodat-
kowych bibliotek może wpływać na szybkość wykonywania operacji. W niniejszej pracy przedstawiono czasową anali-
zę dotyczącą wykonywania operacji bazodanowych insert, update, delete i select dla trzech systemów baz danych
MySQL 8.0, PostgreSQL 14.1 i Oracle 21c, współpracujących z aplikacją wykorzystującą biblioteki Doctrine. Badania
wykazały różnice między wykonywaniem operacji wraz z mapowaniem obiektowo-relacyjnym, a wykonywaniem sa-
mych zapytań. Przy współpracy z aplikacją, operacje najszybciej przeprowadzono korzystając z systemu PostgreSQL.
System Oracle szybciej wykonywał operacje pobierania danych bez udziału mapowania na dużym zbiorze danych.
Słowa kluczowe: relacyjne bazy danych; Doctrine; ORM; PHP
*
Corresponding author
Email address: marcinchoina1997@gmail.com (M. Choina)
©Published under Creative Common License (CC BY-SA v4.0)

1. Introduction
1.1. Doctrine
Database systems are a common method of data storage
Doctrine is an open source library set for PHP technolo-
today. They are used in various types of IT systems,
gy under the MIT (the Massachusetts Institute of Tech-
computer programs and applications. Currently, data-
nology) license. It is the default communication mecha-
bases can be divided into several types (e.g. noSQL,
nism with the database for the Symfony framework and
object-oriented, hierarchical), but the most common
can be much more efficient compared to other mecha-
choice for application development are relational data-
nisms, e.g. Propel library [2]. The Doctrine abstraction
bases [1]. There are many free and commercial relation-
layer (DBAL) enables cooperation with many available
al database management systems available on the mar-
database systems. Additionally Doctrine is based on
ket, differing in capabilities and speed of operations.
object-relational mapping (ORM) technology that al-
The performance is also influenced by the technology
lows to present information retrieved from the database
in which the application using the database is created
using entity class objects. This solution allows to signif-
and the operating system on which it is run.
icantly improve the quality of the code and enables
This paper aims to compare the time performance of
faster information management in the database [3].
MySQL 8.0, PostgreSQL 14.1 and Oracle 21c database
Doctrine supports relationship mechanisms, which is
systems running with an application using Doctrine
achieved through associations between class objects.
libraries, one of the most popular and fast technologies
They make it possible to refer to other objects, and the
using object-relational mapping, allowing for the con-
library ensures that the relevant data is retrieved from
nection of an application written in PHP with the data-
the database [4].
base. The performed tests allow to verify the time of
operations and assess which database systems are the 1.2. MySQL
fastest and the slowest in carrying out operations of
inserting, updating, deleting or selecting data, using, MySQL is a database system licensed under the GNU
GPL license, currently developed by Oracle [5]. It is
among others, the mechanisms of sorting, grouping and
supported by a large number of technologies as well as
joining tables.

250
Journal of Computer Sciences Institute 24 (2022) 250-257

by the most popular programming languages such as sys.dm_exec_query_stats for MS SQL. The operations
PHP, Java, C ++, and it can be used on all popular oper- were performed on a set of 500-100,000 records for text
ating systems [6]. It is also part of the server environ- or numeric data and on a set of 1-50 records for binary
ment on the Linux - LAMP platform. data larger than 50MB, and the cache was cleared after
each action. The results showed that the MS SQL data-
1.3. PostgreSQL
base performs DML (Data Manipulation Language)
PostgreSQL is an advanced database system released operations such as inserting and updating data better.
under the PostgreSQL license, which is very similar The Oracle database is much better suited for DQL
to the MIT license. The system introduces many propri- (Data Query Language) operations, which means da-
etary extensions to the implementation of the SQL ta selecting.
standard. It enables the creation of stored procedures in Authors of many articles compare Oracle, SQL
various programming languages such as Python or Perl. Server and MySQL databases. Examples of this com-
PostgreSQL is a combination of a relational and object- parison are the articles [12], [13]. In the first one, the
oriented database system, which allows for a more pre- time of updating one column of a table, transferring
cise adaptation of the database to the needs of the appli- records to another table, and selecting records using
cation being created [7]. sorting, grouping and joining tables in a database sys-
tem running on a home computer was examined. The
1.4. Oracle MySQL was the best for most operations in this case. In
The Oracle database management system is a commer- the second article, the authors compared these relational
cial solution released by Oracle Corporation under databases with non-relational databases such as Mongo,
a paid license [8]. There is also a free version, the Ex- Redis, GraphQL and Cassandra, where the times of
press Edition, with limited functionality. Like Post- basic operations were compared. The obtained results
greSQL, it contains elements of an object-oriented data- confirmed that queries to non-relational databases were
base system. It also provides its own PL / SQL lan- executed much faster than in the case of relational data-
guage, which enables the extension of standard func- bases. Considering relational systems, in the Oracle
tionalities to automate some activities carried out in system there has been achieved one of the fastest data
the database. selection times.
Currently, various frameworks or libraries are used
2. Related works to support the application development process, as well
Many scientists analyzed the differences between indi- as connecting to the database and managing the data
vidual database solutions, their capabilities and perfor- stored. Since the libraries are designed so that they can
mance. The authors of the article [9] chose to compare cooperate with various database systems, they can have
various relational database systems, Oracle Database an impact on the efficiency of performed operations.
19c, SQL Server 2019, PostgreSQL 12 and MySQL 8. One of the most popular frameworks for creating web
For this purpose, on each of them they created a data- applications in PHP language are Symfony and Laravel.
base according to the same scheme, and then tested on it For Symfony, the preferred way to communicate with
data selecting, grouping, and inserting operations the database is to use Doctrine libraries, while Laravel
as well as backup and restoring data. These tests showed has its own mechanism Eloquent ORM [14]. In the
differences in the performance of databases, where the article [15], the authors examine the performance of
most efficient in terms of time turned out to be the Ora- relational databases cooperating with an application
cle and SQL Server systems, and the MySQL system written using the Laravel framework. The test consisted
was the worst. in comparing the average execution times of operations
Oracle and SQL Server databases are commercial such as insert, update, delete and select on a database
solutions which were compared by the authors of arti- running on mid-range hardware. To the research open
cles [10], [11]. The first one presents an analysis of the source databases such as MySQL 8 and PostgreSQL 12
differences and performance of the servers in the given and the commercial Microsoft SQL Server 2017 were
databases. The research presents the advantages of the used. The results showed that in the case of a small
Oracle database, which has better accessibility, in terms number of records stored in the database (up to 1000
of the possibility of installation on various operating records), MySQL was the best solution, while with
systems and support by a larger number of program- a larger number of records, the PostgreSQL system
ming languages, as well as having multi-layer security. turned out to be better.
On the other hand, MS SQL is supported by simpler Another article presents the analysis of MySQL, MS
language syntax and better query performance for single SQL and PostgreSQL database systems in the context of
and joined tables. In the second of the mentioned arti- web applications using the Spring framework, the Hi-
cles, the performance of these systems was compared bernate library and the JDBC interface [16]. In the case
with the use of a desktop application. In the study, an of database cooperation with a web application, Post-
external application was used to perform various actions greSQL turned out to be the most efficient system for
on the database, and the execution time of a given ac- complicated operations on joined tables, using both the
tions was taken from the views of the database system Hibernate library and the JDBC interface. In the case of
such as V$SQL for the Oracle database and a single table, the average times of performing opera-

251
Journal of Computer Sciences Institute 24 (2022) 250-257

tions were similar, and when performing operations each table of the tested database, which was 1,000,
directly on the database, MS SQL was the most opti- 10,000 or 100,000 records, respectively.
mal system. The following activities were performed during
In all above-mentioned articles, authors focused the study:
mostly on comparing the average times of performing  selecting one of the operations (Table 1),
basic operations on the database. In the article [17] the  test of operations on MySQL database,
authors also analyzed the CPU load and the memory  test of operations on PostgreSQL database,
usage, and the authors of the article [9] examined the  test of operations on Oracle database,
times of making and restoring a database backup. In  restoring the initial state of databases.
most studies one model to build the database was used
for each tested system. Some researchers used an addi- Before each test, the cache of the database system
tional application [11] or technology [15, 16], but few and application was cleared, and the entire test was
studies were related to the cooperation of databases with repeated 10 times for each operation. Computer with the
Doctrine libraries. following parameters was used for the tests:
Based on the literature analysis, the following hy-  Intel® Core™ i5-10300H processor,
potheses were made:  8GB DDR4 2400 MHz RAM,
 Insert, update and delete operations should be per-  Xioxia BG4 512GB NVMe SSD,
formed the fastest by the PostgreSQL database in  Windows 10 64-bit operating system.
cooperation with the Doctrine library,
 The Oracle database should perform the operations Table 1: Database operations
of selecting data the fastest with a large number of Operation Query
records (100,000) in the table. Insert one row into INSERT INTO appuser val-
3. Research method the table ues ( 100001, “Adam”,
”Nowak”, ”anowak”, ”an-
In this paper, it was decided to compare the average owak@pollub.pl”,
times of performing select, insert, update and delete ”zaq1@WSX” )
operations. These times were measured for the query Update one row in UPDATE appuser SET name
with object-relational mapping on the data and with- a table = “Marek” WHERE id = 567
out it. For the needs of the research, an application that Delete one row from DELETE FROM task_user
uses Doctrine libraries has been created. It contained the table WHERE id = 567
a module that allows to test the database. On each tested Select all rows from SELECT * FROM appuser
system, a database based on the model shown in Fig- one table
ure 1 was created. Select all rows sorted SELECT * FROM appuser
The research was carried out according to a scenario. ORDER BY surname, name
The purpose of the study was to verify the time of per- Select rows using SELECT * FROM appuser
forming subsequent operations specified in Table 1, pattern search WHERE UPPER(name)
depending on the used database system and the number LIKE ‘%ADA%’
of records stored in the database tables. The initial con-
Select one row from SELECT * FROM appuser
dition for the study was a fixed number of records in
a table based on the WHERE id = 567
primary key
Select rows with join- SELECT * FROM course c
ing tables using JOIN INNER JOIN appuser u ON
construction u.id = c.owner_id INNER
JOIN task t ON t.course_id =
c.id
Select rows with join- SELECT * FROM course c,
ing tables using appuser u, task t WHERE u.id
WHERE construction = c.owner_id AND
t.course_id = c.id
Select rows using SELECT c.* FROM course c
grouping functions LEFT JOIN task t ON
t.course_id = c.id GROUP
BY c.* HAVING
count(t.id) = 0
Select rows using SELECT t.* FROM task_user
a correlated query t WHERE grade_value = (
SELECT MAX(grade_value)
Figure 1: Database model. FROM task_user tu1 WHERE
t1.user_id = t.user_id )

252
Journal of Computer Sciences Institute 24 (2022) 250-257

4. Results achieved than for Oracle database, but for this system
the application processed the entity object into a query
The first tested operations were DML queries. First,
much longer. The application did not take a long time
insert of single user operation were tested (Figure 2-3).
(18-21ms) to process the object to insert it into the
The results do not vary significantly depending on the
Oracle database, which shows that this system works
number of records in the tables for each database
quicker with the application than MySQL.
system. This type of operations for both the query with
The results of the update and data delete operation
mapping and without it were executed the quickest in
(Figure 4-7) were similar to the data insert operation. The
the PostgreSQL database. With the other systems, insert
fastest execution times were achieved using PostgreSQL
operations were performed much slower. By performing
database.The results of the other two systems differ
the query without mapping to the database, using the
depending on whether the object-relational mapping was
MySQL database the shorter execution time was
considered. The shorter time was gained performing

Figure 2: Average time of INSERT operation. Figure 5: Average time of UPDATE operation with ORM.

Figure 3: Average time of INSERT operation with ORM. Figure 6: Average time of DELETE operation.

Figure 4: Average time of UPDATE operation. Figure 7: Average time of DELETE operation with ORM.

253
Journal of Computer Sciences Institute 24 (2022) 250-257

Figure 8: Average time of select one row operation. Figure 11: Average time of select all data operation with ORM.

Figure 9: Average time of select one row operation with ORM. Figure 12: Average time of select sorted data.

Figure 10: Average time of select all data operation. Figure 13: Average time of select sorted data with ORM.

update operation in cooperation with the application using of DML operation studies (Figures 8-9). In the
the Oracle database than MySQL. Using the MySQL PostgreSQL database the data from the database has
system theshorter time was obtained performing the update been obtained the fastest, but regarding to other
query without cooperating with the application. Aditionally databases, the performing query wihout mapping was
the MySQL system performed the delete operation with faster with MySQL database than whit Oracle. While
and without object-relational mapping faster than the cooperating with the application, the longest times were
Oracle system. obtained for a large number of records (i.e. 100,000)
Next operations belong to the group of DQL using the Oracle system. With less number of records in
instructions that allow to retrieve specific data from the the tables, its results were similar to the MySQL system.
database. One of the most commonly used operations is When selecting all the rows from the database
selecting one row from a table based on its primary key. (Figures 10-11), with PostgreSQL the shortest average
The results of this operation were similar to the results time was obtained when the number of records in the

254
Journal of Computer Sciences Institute 24 (2022) 250-257

Figure 14: Average time of select operation using pattern search. Figure 17: Average time of join operation using JOIN construction
with ORM.

Figure 15: Average time of select operation using pattern search


with ORM. Figure 18: Average time of join operation using WHERE construc-
tion.

Figure 16: Average time of join operation using JOIN construction. Figure 19: Average time of join operation using WHERE construction
with ORM.
tables was low or medium (up to 10,000). With a larger
number of records, the operations were performed much (Figures 12-15) on a table with a large number of rows
faster using the Oracle system, for which the average (i.e. 100,000). With fewer numbers, PostgreSQL
operation execution time decreased while the number of performed queries the quickiest. The MySQL system
records increased. However, when working with the with a large number of records in the tables, carried out
application, using the Oracle database the longest times both operations several times longer than the other
were achieved and the best times were obtained using systems. Regarding mapping with a large number of
the PostgreSQL database, regardless of the number of records (i.e. 10,000), there have been obtained a very
records in the tables. similar result for the Oracle and the PostgreSQL system
In the Oracle the best times were obtained when when sorting. When searching for pattern, the time was
executing select queries using sort or pattern search up to 27% shorter using Oracle system.

255
Journal of Computer Sciences Institute 24 (2022) 250-257

Figure 20: Average time of group operation. Figure 22: Average time of select operation using correlated query.

Figure 21: Average time of group operation with ORM. Figure 23: Average time of select operation using correlated query
with ORM.
When operations of joining the tables were
performed, the results for both tested methods were 5. Discussion
similar (Figures 16-19). The Oracle system was very
quick at executing a query for a large number of records In the study, in addition to various database systems, the
in the database, while for a smaller number of records, number of records in the tables of a given database, and
the shortest time was achieved using the PostgreSQL whether object-relational mapping was used, was taken
system. When cooperating with the application, in the into account. For different database systems, when
PostgreSQL database the best time was achieved, executing the query without mapping, for data
regardless of the number of records, but also using the manipulation operations and for the rest of operations
MySQL system a very similar average execution time where the number of records in database tables was less
was acheved. than 100,000, PostgreSQL perform operations the
For the grouping operations, the best times were fastest. With the Oracle system the shortest times was
obtained using PostgreSQL database with and without obtained for almost all data select operation when the
mapping (Figures 20-21). The Oracle system performed number of records in the tables was 100,000, except for
operations for small and medium number of records (up retrieving a record using a primary key and using
to 10,000) the slowest, while in MySQL system the grouping. The obtained result confirmed the results of
slowest execution time was obtained for a large number the research in articles [9] and [13], in which the Oracle
of records stored in tables. system performed select operations the fastest, when the
For the select operation using correlated query (Fig- operation was performed directly on the database.
ures 22-23), while executing the query without object- Results vary depending on whether cooperation with
relational mapping on a large number of records the application was used, that means executing query with
shortest time was obtained using Oracle database. With object-relational mapping. Regarding the select
a smaller number of records in the table, or when the operation with a like clause, on a table containing
object-relational mapping was performed, the quickest 100,000 records, using Oracle database system the
times were gained using PostgreSQL database. significantly shorter time was obtained comparing to
other analyzed database systems. Analising query
execution with obiect-relational mapping, operations
were performed even several times faster using the

256
Journal of Computer Sciences Institute 24 (2022) 250-257

PostgreSQL system. That confirmed the results obtained [3] M. Lorenz, G. Hesse, J. Rudolph, Object-relational
in the article [16], in which, the PostgreSQL system Mapping Revised - A Guideline Review and
performed the operations the fastest using additional Consolidation, Proceedings of the 11th International Joint
technology. Conference on Software Technologies - ICSOFT-EA,
(2016) 157-168,
The operation execution time increases when object- https://doi.org/10.5220/0005974201570168.
relational mapping is performed. Regarding the DML
operations executed by the MySQL database, the per- [4] Doctrine documentation, https://www.doctrine-
formed queries with mapping lasted even 10ms longer project.org/index.html, [03.11.2021].
than the queries without it. The difference for time que- [5] MySQL documentation, https://dev.mysql.com/doc/ref
ry execution with and without object-relational mapping man/8.0/en/introduction.html, [26.05.2022].
for other analyzed database systems varied from 1 to
[6] Supported Platforms: MySQL Database,
2 ms. For the select operations, the mapping time de- https://www.mysql.com/support/supportedplatforms/da
pended on the number of records stored in the database. tabase.html, [24.01.2022].
The biggest difference between performing operations
with and without mapping occurred for the Oracle data- [7] PostgreSQL website,
base for a large number of records in the tables (i.e. https://www.postgresql.org/about/, [26.05.2022].
100,000). This database system executed the query [8] Oracle documentation, https://docs.oracle.com/en/datab
without mapping the fastest, but with the mapping the ase/oracle/oracle-database/21/cncpt/introduction-to-
execution times were the longest. When all rows were oracle-database.html, [26.05.2022].
selected, the system performed operation up to 50 times [9] A. Solarz, T. Szymczyk, Oracle 19c, SQL Server 2019,
longer with mapping than without it. Postgresql 12 and MySQL 8 database systems
Based on the gathered results, it can be concluded comparison, Journal of Computer Sciences Institute 17
that the first hypothesis, which is that insert, update and (2020) 373-378, https://doi.org/10.35784/jcsi.2281.
delete operations should be performed the fastest by the [10] M. Ilić, L. Kopanja, D. Zlatković, M. Trajković, D.
PostgreSQL database in cooperation with the Doctrine Ćurguz, Microsoft SQL Server and Oracle: Comparative
library, was confirmed. PostgreSQL always performed performance analysis, The 7th International conference
operations of inserting, updating and deleting data the Knowledge management and informatics (2021) 33-40.
fastest. The second hypothesis, that the Oracle database
[11] G. Dziewit, J. Korczyński, M. Skublewska-
should perform the operations of selecting data the fast- Pawszkowska, Performance analysis of relational
est with a large number of records (i.e. 100,000) in the databases Oracle and MS SQL based on desktop
tables, could be partially confirmed. Oracle database application, Journal of Computer Sciences Institute 8
executed most of the queries for selecting data from (2018) 263-269, https://doi.org/10.35784/jcsi.693.
tables with a number of 100,000 records the fastest.
[12] K. Islam, K. Ahsan, S. Bari, M. Saeed, S. Ali, Huge and
However, in cooperation with the application, the opera- Real-Time Database Systems: A Comparative Study and
tion time was significantly increased in favor of the Review for SQL Server 2016, Oracle 12c & MySQL 5.7
PostgreSQL system. for Personal Computer, Journal of Basic & Applied
Sciences 13 (2017) 481-490, https://doi.org/10.6000/1927-
6. Conclusions
5129.2017.13.79.
In the presented paper, the times of various database [13] R. Čerešňák, M. Kvet, Comparison of query
systems were tested and compared while working with performance in relational a non-relation databases,
the Doctrine library, which allowed to verify the hy- Transportation Research Procedia 40 (2019) 170-177,
potheses. The study showed that the PostgreSQL system https://doi.org/10.1016/j.trpro.2019.07.027.
is the fastest solution when working with an application
[14] Eloquent documentation, https://laravel.com/docs/5.0/e
using Doctrine libraries. The Oracle system works the loquent/, [26.05.2022].
best when performing select queries without mapping to
the database. The research focused on the time of per- [15] R. Wodyk, M. Skublewska-Paszkowska, Performance
formed operations, which is the most noticeable feature comparison of relational databases SQL Server, MySQL
of databases for the end user. Other aspects such as and PostgreSQL using a web application and the Laravel
framework, Journal of Computer Sciences Institute 17
CPU load and memory utilization were not analyzed,
(2020) 358-364, https://doi.org/10.35784/jcsi.2279.
which may be an interesting direction of future research.
[16] K. Lachewicz, Performance analysis of selected database
References systems: MySQL, MS SQL, PostgerSQL in the context of
[1] T. Connolly, C. Begg, Database Systems, A practical web applications, Journal of Computer Sciences Institute
approach to Design, Implementation, and Management, 14 (2020) 94-100, https://doi.org/10.35784/jcsi.1583.
sixth edition, Pearson, 2015. [17] Y. Bassil, A Comparative Study on the Performance of
[2] K. Sawłuk, M. Miłosz, Comparison of object-relational the Top DBMS Systems, Journal of Computer Science
data mapping technology in Symfony 3 framework, & Research 1 (1) (2012) 20-31,
Journal of Computer Sciences Institute 8 (2018) 235- https://doi.org/10.48550/arXiv.1205.2889.
240, https://doi.org/10.35784/jcsi.687.

257

You might also like