# mySql or Postgresql, that is the question?

**URL:** <https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937>\
**Category:** Rails\
**Created:** [March 23, 2007, 11:49pm UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937 "2007-03-23T23:49:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@dima](https://www.ruby-forum.com/u/dima)\
**Post date:** [March 23, 2007, 11:49pm UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937/1 "2007-03-23T23:49:30Z")

</div>

I have to decide witch database to use in a Rails project for the  
client.  
It has to do with some payment system and should be fast.

I have more knowledge about mySql but Postgresql looks like a better  
choice because of the transactions.

In most posts I find a mySql as used data base engine.

Is there any particular reason to prefer mySql over Postgresql?

Please don’t make this in a “my choice is better than yours” war I  
need to make the right selection and from the clever reasons.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@dima](https://www.ruby-forum.com/u/dima)\
**Post date:** [March 24, 2007, 12:32am UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937/2 "2007-03-24T00:32:02Z")

</div>

dima wrote the following on 23.03.2007 23:48 :

> I have to decide witch database to use in a Rails project for the  
> client.  
> It has to do with some payment system and should be fast.
> 
> I have more knowledge about mySql but Postgresql looks like a better  
> choice because of the transactions.

MySQL supports transactions when using InnoDB. PostgreSQL and MySQL have  
roughly the same performance in this case.

PostgreSQL is more stable, standards compliant and uses less RAM.  
MySQL supports replication out of the box and can mix InnoDB and MyIsam,  
which can help with performance in some cases.

Lionel.

---

<div class="post-metadata">

**Author:** ![dima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@dima](https://www.ruby-forum.com/u/dima)\
**Post date:** [March 24, 2007, 12:35am UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937/3 "2007-03-24T00:35:02Z")

</div>

I routinely use both for Rails projects. I notice a quirk with the  
Postgres driver once in a while when putting together large dynamic  
find queries, but you’ll probably be fine with either.

Preston

---

<div class="post-metadata">

**Author:** ![dima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@dima](https://www.ruby-forum.com/u/dima)\
**Post date:** [March 24, 2007, 12:39am UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937/4 "2007-03-24T00:39:03Z")

</div>

> > I have to decide witch database to use in a Rails project for the  
> > client.  
> > It has to do with some payment system and should be fast.
> > 
> > I have more knowledge about mySql but Postgresql looks like a better  
> > choice because of the transactions.
> > 
> > In most posts I find a mySql as used data base engine.
> > 
> > Is there any particular reason to prefer mySql over Postgresql?

I think most people go with MySQL because it’s more popular… which  
makes it  
more popular, which makes more people go with MySQL, etc. 🙂

If your database needs don’t go beyond what ActiveRecord can do, then  
either  
is fine. For one of my projects, I am using Postgres, specifically  
because I  
want to use table triggers and stored procedures and the like, and  
postgres’s procedural language (“plpgsql”) is far better and closer to  
the  
SQL standard than MySQL’s.

Oh, and you can use ruby as a database procedural langauge in postgres  
now  
too. 🙂 Although that kind of seems like putting the cart before the  
horse…

```
- Tyler
```

---

<div class="post-metadata">

**Author:** ![dima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@dima](https://www.ruby-forum.com/u/dima)\
**Post date:** [March 26, 2007, 8:56am UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937/5 "2007-03-26T08:56:22Z")

</div>

Thank you all for you time and effort to enlighten me.

I will go for Postgresql at the moment. With db migration it would be  
much of a problem to switch to any other database (mySql or DB2) if  
such need emerge.

As this project of mine progress I will share my experience with you.

---

<div class="post-metadata">

**Author:** ![dima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@dima](https://www.ruby-forum.com/u/dima)\
**Post date:** [March 24, 2007, 2:21am UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937/6 "2007-03-24T02:21:09Z")

</div>

On Friday 23 March 2007, dima wrote:

> I have to decide witch database to use in a Rails project for the  
> client.  
> It has to do with some payment system and should be fast.
> 
> I have more knowledge about mySql but Postgresql looks like a better  
> choice because of the transactions.
> 
> In most posts I find a mySql as used data base engine.
> 
> Is there any particular reason to prefer mySql over Postgresql?

In the cases that mattered to me, PostgreSQL syntax is closer to the SQL  
standard than MySQL’s is.

If you declare a column as NOT NULL in MySQL (at least up to version 4),  
you get default values for that column whether you want them or not.

PostgreSQL supports transactional changes to the database schema.  
There’s even a plugin that makes migrations transactional without any  
further work  
([http://agilewebdevelopment.com/plugins/transactional\_migrations](http://agilewebdevelopment.com/plugins/transactional_migrations)).

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)

---

<div class="post-metadata">

**Author:** ![dima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@dima](https://www.ruby-forum.com/u/dima)\
**Post date:** [March 26, 2007, 7:07pm UTC](https://www.ruby-forum.com/t/mysql-or-postgresql-that-is-the-question/89937/7 "2007-03-26T19:07:52Z")

</div>

If you are going to be dealing with money, then you need a formal  
transaction boundary. In that case I believe that Postgresql is the  
more appropriate choice.

I haven’t used either much, yet. I’m just starting with a project  
that has the same question, and the choice we made is the suggestion  
I’m making to you. Postgresql and MySql are comparable in  
performance, so until the next version of Firebird is released and  
shaken out, Postgresql is likely the best choice for a free database  
that has defined transaction boundaries.
