Database Benchmarks. Postgre VS MySQL
Monday, 28 September 2009 13:08

This is a benchmark test on three of the most used database engines MySQL, PostgreSQL and SQLite
SQLite is used only to show us how much better the things could be :)

WARNING: Know that this test is with the base databases instalation. No additional optimization are made to database engines.
We know that is we optimize them the results will be copletely different but that is not the point of this benchmark.

Test is performed on 7.2-STABLE FreeBSD 7.2-STABLE amd64
Database versions are:

PostgreSQL 8.4.0
MySQL 5.0.86
SQLite3 3.6.14.2


The perf create statement is:
CREATE TABLE `perf` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '',
PRIMARY KEY  (`id`)
)
NOTE: In MySQL database it is set as MyISAM type. PostgreSQL has no table types.

1. First we perform 999999 insert queries.
Example: INSERT INTO perf (name) VALUES (i) Where i is incremental name with some prefix

PosgreSQL start time 2009-09-25 16:42:05
PosgreSQL end time 2009-09-25 16:55:45

MySQL start time 2009-09-25 16:55:45
MySQL end time 2009-09-25 16:57:21

SQLite start time 2009-09-25 17:19:57
SQLite end time 2009-09-25 17:20:39

2. Second step is to walk arround all the records and update each one with different prefix
Example: UPDATE perf SET name = 'a_i' WHERE id = i Where i is incremental integer

PosgreSQL start time 2009-09-28 12:34:12
PosgreSQL end time 2009-09-28 12:49:35

MySQL start time 2009-09-28 12:54:42
MySQL end time 2009-09-28 12:56:53

SQLite start time 2009-09-28 13:02:20
SQLite end time 2009-09-28 13:03:15

3. Third step is to make 300 queries selecting random number of fields between id > random number and id < random number
Example: SELECT * FROM perf WHERE id > [random_start] AND id < [random_end]
Where random_start < random_end and the range is allways insite the racords range


PosgreSQL start time 2009-09-29 09:30:01
PosgreSQL end time 2009-09-29 09:35:09

MySQL start time 2009-09-28 15:42:56
MySQL end time 2009-09-28 15:46:42

Intresesting! Nothing to say about that. We can't check it with only 300 queries ...
SQLite start time 2009-09-28 15:46:42
SQLite end time 2009-09-28 15:46:42

... thats why we made it With 100000 queries :)
SQLite start time 2009-09-28 15:48:20
SQLite end time 2009-09-28 15:48:35

 

Download python source code of the test here

 
Open Organisation Ergon, Powered by Joomla!; Joomla templates by SG web hosting
viagra for sale | viagra price canada | viagra online pharmacy | cial | cialis professional online | viagra online no prescription | order viagra | generic viagra no prescription | buy cialis | discount viagra canada | real viagra | cialis generic india | viagra price