views:

1922

answers:

7

I will soon be switching from sqlite3 to either postgres or mysql. What should I consider when making this decision? Is mysql more suited for Rails than postgres in some areas and/or vice versa? Or, as I somewhat suspect, does it not really matter either way?

Another factor that might play into my decision is the availability of tools to data pump my test data from the sqlite3 db to my new one. Is there anything that ActiveRecord provides natively to do this or any decent plugins/gems to help with this task?

BONUS: How do I pronounce "Postgresql" and sound like I know what I'm talking about? :)

Thanks Greg Smith for providing the following link that shows the most common pronunciations:

http://www.postgresql.org/community/survey.33

UPDATE:

Reference this question for more:

http://stackoverflow.com/questions/110927/do-you-recommend-postgresql-over-mysql

FYI:

I ended up using MySQL. There is a neat plugin called yamldb that really saved me some time with the data transfer from my sqlite db to my new mysql one. Instructions on how to install and use it can be found here:

http://accidentaltechnologist.com/ruby/change-databases-in-rails-with-yamldb/

Thanks

Tom

+6  A: 

Rails should be using standard SQL statements to access your data. If this is true, conceptually there should be little difference between the two databases.

Anecdotally, there is evidence that MySQL is somewhat faster, but that Postgresql scales better as the database gets larger.

If I understand the licenses correctly, MySQL is more of a "free as in speech" database, where Postgresql is "free as in speech" and "free as in beer."

SQLite has lots of ways to get data INTO SQLite, including a Postgresql process. I didn't see anything going the other way though. It should be simple enough to work up some SQL statements.

Robert Harvey
+1 for the most non-committal answer I've ever seen in "PostgreSQL vs MySQL" discussions :-)
ChssPly76
I have a soft spot for Postgresql, even though MySQL seems to be more popular.
Robert Harvey
PostgreSQL is under the BSD license (http://www.postgresql.org/about/licence). Its hard to get much more free-as-in-speech than that.
derobert
That's right. Postgresql is "free as in speech" AND "free as in beer." Confused?
Robert Harvey
MySQL is free in both senses, as in PostgreSQL. Well, the license of *both* of them allow you to sell the software, but both are available for free and both have people willing to sell you support. It'd be fair to say that PostgreSQL is more of a community effort (I think, not completely sure), whereas MySQL is largely developed by the company backing it (or not, since Oracle bought it).
derobert
+4  A: 

I'm not sure of the technical comparison between the most recent versions of the systems, but I do know there are non-technical factors which you might want to weigh in your decision.

MySQL got bought by Sun which subsequently got bought by Oracle. There were quite a few articles on the decline of quality of MySQL since the founders sold it.

There are other free dbs as well, but i think Postgresql sounds like a good choice.

mson
I didn't know that, although I don't follow the MySQL ticker tape regularly.
Robert Harvey
i used to love MySQL and used to send them money. a while ago, MySQL was the only choice for cheap db... SQL Server\DB2\Oracle were too expensive and postgresql used to be too complex to manage. mysql forced oracle and microsoft to release free versions of their product and for the postgresql guys to make their tool more dummy friendly. i admire the founders for what they did in the time they did it in. i did run into technical issues with mysql and complex queries - it did not know how to handle them efficiently, but i don't know if they've fixed these issues yet.
mson
That was actually the primary impetus for the question. I was originally gung-ho on going with MySQL (for no particular reason other than it has always irked me that I'm never quite sure how to say "postgresql" :)), when my collaborator on this project mentioned the fact that it had gone downhill recently.
cakeforcerberus
@semirhage: /poːst ɡɹɛs kjuː ɛl/ (post gress cue ell); at least according to Wikipedia (http://en.wikipedia.org/wiki/PostgreSQL)
derobert
A: 

MySQL is a lot more popular than PostgreSQL. That's not an important technical consideration, but when it comes to finding people who can help you solve problems, it can be a big deal. Up to a certain size database, it won't matter, but when your database starts getting big and you run into performance problems, it can be advantageous to be able to tap into the MySQL community.

Rafe
The PostgreSQL community is very easy to tap into via the quite active mailing lists related to the database. Things like performance problems often get answered directly by the developer who wrote the code involved. That only helps out if, like PostgreSQL itself, you're willing to be completely open about what you're doing. If whatever you're doing is secret and you can't describe the problems you run into publicly, there I can see that having a wider number of private MySQL community members to pull from for help might be important.
Greg Smith
+2  A: 

It depends on the projected scale of your web application. For relatively small databases, MySQL is fine and is slightly faster for simple selects, etc. Once your database gets large however, MySQL hits a wall where PostgreSQL just keeps on driving through it.

As long as you're using ActiveRecord for your middleman, it won't matter what database you use, as it builds Standards Compliant SQL Statements, which will work on both databases. As soon as you specify any triggers, stored procedures, etc, you'll be stuck with one database.

I personally prefer PostgreSQL, but that's just because I was never a big fan of MySQL.

PS: I pronounce it as "Postgres".

Mike Trpcic
Don't take the bait to introduce your holy opinion... if you have nothing useful to say don't say it.
MarkR
If you actually read my post, the only mention of opinion is the last sentence. The rest is the truth. ActiveRecord will not care unless you do DB specific things. PostgreSQL is better at complicated things, MySQL is faster for simple things.
Mike Trpcic
+12  A: 

It's pronounced Post-gres-Q-L; see the official recording. A good sized chunk of people just use "Postgres" all the time instead. There's a survey showing the relative popularities of the various other and less popular incorrect pronunciations, most of these are accepted by community members anyway, except for calling it "Postgre" which annoys all the regulars.

I wrote a long piece comparing MySQL vs. PostgreSQL in terms of speed and reliability, touching briefly on development model. Since then, Postgres has continued to make steady forward progress with a unified community producing completely free software. Meanwhile, MySQL has wandered into this split community going in all directions and with a downright frightening owner of the original code. It's pretty crazy, and if you value really free software the only reason I could see for using MySQL at this point if is you already have an app that only runs on that database.

Greg Smith
Nice link to survey, thanks :) +1
cakeforcerberus
+1  A: 

Either choice is not going to be a bad one.

If you have no legacy and are starting fresh, I would recommend PostgreSQL mainly since it's quite mature, and have nifty features.

One thing that you might want to consider is if you need replication though, which really requires some black magic(or commercial support) with PostgreSQL. Repplication in mysql is prety straight forward though

nos
A: 

@Rafe thanks guys! Any technical details you can add? Replication solutions, full text search, any oddities you ran into, anything like that would be appreciated!

Exchange
This should be a comment added to a reply.
Ein2015