PostgreSQL vs MariaDB(MySQL) 2015
Important Notice (13 Feb 2016)
When using pgadmin, the execution time at status bar is including data transfer time, unfortunately, I am using pgadmin status bar execution time to compare with MySQL server execution time which is unfair. I will update the correct benchmark soon.
Please Refer to this updated benchmark
Choosing RDBMS
So recently I want to find benchmark for RDBMS between MySQL/MariaDB and PostgreSQL. To my surprise, most benchmark result is outdated, therefore I have decided to benchmark them, using MariaDB(MySQL) [10.0.22(5.6.26)] vs PostgreSQL [9.2.14]
How to Benchmark
- Using similar table structure: located at {db}.sql
- Use python script to generate sql insert data
- Open sqlyog to benchmark MariaDB(MySQL)
- Open pgAdmin to benchmark PostgreSQL
- All setting are using default: setting related file can be found at {benchmark_folder}/{db}_config.txt
You can find the detail at my Repo
Result
- mariadb(mysql) write (10000 rows): from insert.sql, run 10x time accumulate to 100000 rows
- 0.281s
- 0.131s
- 0.165s
- 0.146s
- 0.248s
- 0.141s
- 0.136s
- 0.208s
- 0.157s
- 0.155s
- postgresql write (10000 rows):
- 0.227s
- 0.256s
- 0.215s
- 0.227s
- 0.194s
- 0.195s
- 0.203s
- 0.205s
- 0.174
- 0.182s
simple query: taking average of multiple time query
SELECT * FROM testing LIMIT 1000
- mariadb(mysql):0.007s
- postgresql: 0.045s
SELECT * FROM testing WHERE int_col > 5000 LIMIT 1000
- mariadb(mysql):0.007s
- postgresql: 0.045s
SELECT * FROM testing WHERE int_col + int_col2 > 12345
- mariadb(mysql): 0.008s
- postgresql: 0.045s
SELECT COUNT(*) FROM testing WHERE int_col + int_col2 > 12345
- mariadb(mysql): 0.040s
- postgresql: 0.021s
SELECT * FROM testing WHERE int_col > 5000 ORDER BY word_col ASC LIMIT 1000
- mariadb(mysql): 0.106s
- postgresql: 0.093s
SELECT * FROM testing WHERE word_col LIKE '%lim%' ORDER BY word_col DESC LIMIT 1000
- mariadb(mysql): 0.093s
- postgresql: 0.058s
Conclusion
MariaDB(MySQL) is good at dead simple query, however PostgreSQL is good at more complicated query.
For real world scenario, it will more likely has a lot of complicated query, therefore its better to choose PostgreSQL for it - provided that PostgreSQL comes with lots of useful feature that MySQL lack of.