views:

1380

answers:

4

I am thinking of working on a Rails application that uses PostgreSQL. I have some questions before I am comfortable using Rails:

  • Is PostgreSQL support in Rails less superior than, say, MySQL.
  • Would it feel any different if using PostgreSQL?
  • Are there any cases where using PostgreSQL fail to work?

Thanks.

+4  A: 

After having used sqlite, mysql and postgresql with Rails, I prefer using postrgresql.

Installation for OSX, Ubuntu and Windows went well as opposed to buggy installs for other DBs.

I had to install the following gem to use postgresql: install gem postgres-pr

It may "feel" different when you come across complex databse requests where you add in special conditions such as extracting the month from a date as the actual text will differ depending on the database system. Also, postgresql delimits strings in request with E'' so sometimes a request using a text-field may come up with an error if you're not careful with your :conditions => [].

Reuben Mallaby
I'm on OSX, that's good to hear. :)
KahWee Teng
Should probably use the pg gem rather than the postgres-pr gem, at least for production. As the pg gem is a c based implementation, and postgres-pr is a pure ruby version. Therefore the pg gem is bound to be faster.
Daemin
+4  A: 

PostgreSQL support with rails is excellent - I would not hesitate to use it.

If you are looking for examples, Planet Argon is a high-profile web development house that primarily does Rails with PostgreSQL in the background. You can read more about their work at Robby Russel's blog.

Heroku uses PostgreSQL exclusively for their Ruby web hosting - including lots of Rails deploys, of course.

Neall
I doubt that I would be using complicated queries but I generally prefer PostgreSQL over MySQL. I just worry that I would encounter problems as most of the Ruby on Rails tutorials are using MySQL instead.
KahWee Teng
+2  A: 

At my employers we use PostgreSQL exclusively, for a large Rails application. We use complex queries etc and so far had no problem with Rails & Postgres itself.

However, if you rely a lot on 3rd party plugins that work on top or beside ActiveRecord, you might want to check their support for Postgres. E.g we ran into inconsistencies using the searchlogic plugin.

effkay
Just to clarify: I use transactions on MySQL all the time. It depends on using the InnoDB storage engine but not a reason to choose Postgres over MySQL. (Not a reason not to either :) )
Shadwell
Oh, yes, you're right, it depends on MySQLs storage engine wether you can have transactions or not. Sorry I got that wrong.
effkay
Please edit your answer according to comments.
the_drow
+1  A: 

Postgres support is very good, albeit support for writing plpgsql functions, triggers and composite primary keys inside migrations leaves much to be desired.

Omar Qureshi
There is a plugin that adds a lot of nice methods for triggers, foreign key constraints, etc.http://github.com/alex3t/rails_on_pg
Jared