Re: MySQL vs. PostgreSQL

From: Arjen van der Meijden <acm(at)tweakers(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: MySQL vs. PostgreSQL
Date: 2002-07-13 13:59:49
Message-ID: agpboc$q9p$1@news.tudelft.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I did notice a considerable difference in time, with a
enquete-result-page (in PHP) using this query:
SELECT
answers.answertext,
answers.answerid,
count(answered_question.answerid) AS answercount
FROM
answers
LEFT JOIN answered_question ON answers.answerid =
answered_question.answerid
WHERE
answers.questionid = '{$this->questionid}'
GROUP BY answers.answerid
ORDER BY answers.answerorder

Which is, I presume, a quite common query...
It runs on exactly the same dataset with exactly the same indices and
table layouts (as far as possible) on exactly the same machine, with
both postgres and mysql optimised 'a bit'.
The query would take 29.45, 55.22 and 17.74 ms on postgresql (for
different questions) takes on mysql respectively: 36.74, 81.14 and 26.37 ms.

Resulting in some simple stats at the end of the page creation:
Database stats Time (s)
Total Execution time: 2.212 s
Total Query time: 2.130 s
Total Number of Queries: 230
Average Time per Query: 0.009 s

vs

Database stats Time (s)
Total Execution time: 3.061 s
Total Query time: 3.002 s
Total Number of Queries: 230
Average Time per Query: 0.013 s

About 150 of these 230 queries are the one showed above. The rest are
simple selects which run 'much' faster on mysql.
The only 'hack' for postgresql I had to make was to set the
ENABLE_MERGEJOIN to OFF, otherwise in some cases it would use the
mergejoin rather than the nested loops on the index scans of both
answers and answered_question, taking over 300ms in stead of 60ms... (a
optimiser problem perhaps?).

Anyway, this shows you that it is not even necessary to have huge
databases, heavy loads or very complicated queries to find postgresql
performing better than mysql.

Regards,

Arjen

Curt Sampson wrote:
> On Fri, 12 Jul 2002, Elaine Lindelef wrote:
> Well, yeah, but it's really time to kill, properly, this idea that
> postgres is always slower than mysql. I'm reasonably convinced that
> under fairly heavy OLTP loads with some large queries going, MySQL would
> grind to a halt at loads much less than postgres can handle.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ewald Geschwinde 2002-07-13 17:05:08 Re: about middleware over postgreSQL....
Previous Message Ravi Malghan 2002-07-13 13:28:59 tcl/tk - postgresql ?