Forum: Ruby on Rails Ruby + Postgres = Bad Idea or Good Idea?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bill S. (Guest)
on 2009-04-17 21:43
Hello,

We're making a development decision soon to use Ruby to develop a front
end for our system.  The backend currently runs on Postgresql.  Some
contractors are pushing us to change the backend database to MySQL,
simply because it's more common to work with Ruby + MySQL.  We prefer
not to support more than one kind of database in house.

We have gotten push back from contractors, who have said, "If it's not
MySQL, I wont bid on it."  I am not a Ruby Developer (IANARD), but I
would like to know if there is an issue with using Ruby + Postgres.
Someone indicated that Ruby + MySQL play nice together, whereas it's
problematic to use other kinds of DBs.

This sounds ridiculous to me, but if I'm missing something, I would love
to hear some opinions.  Is there an issue with support for
Ruby+Postgres?

Thanks,
Bill
Fidel V. (Guest)
on 2009-04-17 22:00
(Received via mailing list)
On Fri, Apr 17, 2009 at 6:43 PM, Bill S.
<removed_email_address@domain.invalid> wrote:
> MySQL, I wont bid on it."  I am not a Ruby Developer (IANARD), but I
> would like to know if there is an issue with using Ruby + Postgres.
> Someone indicated that Ruby + MySQL play nice together, whereas it's
> problematic to use other kinds of DBs.
>
> This sounds ridiculous to me, but if I'm missing something, I would love
> to hear some opinions.  Is there an issue with support for
> Ruby+Postgres?

Hi Bill,

MySQL is almost a de facto standard for web development, and most
people are so ignorant that they think MySQL is the only RDBMS that
plays nicely with any platform. Obviously, it may be the most widely
used RDBMS in web apps, therefore, you will find much more volunteers
to add support for it. But, as far as I know Postgres plays nicely
with Rails. I haven't tried it myself, but I have had people report
that it does work nice with it.

It is true that Rails does not work nicely with a few RDBMSs, but that
has to do with the fact that the majority work with MySQL, hence you
will tend to get more support for MySQL.

If you don't want to lose the contract, then just do what they say: go
with MySQL. The only problem that I see with MySQL is the licensing
scheme, which isn't very attractive.


Fidel.
Gary D. (Guest)
on 2009-04-17 22:00
(Received via mailing list)
Bill S. wrote:
> Hello,
>
> We're making a development decision soon to use Ruby to develop a front
> end for our system.  The backend currently runs on Postgresql.  Some
> contractors are pushing us to change the backend database to MySQL,
> simply because it's more common to work with Ruby + MySQL.  We prefer
> not to support more than one kind of database in house.

I've been using ruby + postgres for many years with no problems at all.
I have also used ruby + Mysql on and off over the past few years and
encountered a few problems with it.

I think if you scan this mailing list archive you will see far more
problem reported about mysql adapters, timeouts etc. than postgres. That
maybe because more people use mysql, it's hard to tell.

> We have gotten push back from contractors, who have said, "If it's not
> MySQL, I wont bid on it."  I am not a Ruby Developer (IANARD), but I
> would like to know if there is an issue with using Ruby + Postgres.
> Someone indicated that Ruby + MySQL play nice together, whereas it's
> problematic to use other kinds of DBs.

My own opinion (no flame wars!) and I know also the opinions of many
others is that postgres is a superior database in almost every respect,
particularly the later (8.2+) versions.

In every scenario I have, postgres has outperformed and remained much
more stable on any meaningful sized databases (1GB to 100GB).

> This sounds ridiculous to me, but if I'm missing something, I would love
> to hear some opinions.  Is there an issue with support for
> Ruby+Postgres?

We currently have a very large rails application using postgres and it
hasn't failed us once. We develop under Windows and Linux and deploy
under Linux and FreeBSD. Windows is fine as long as you use the
postgres-pr gem, mainly because the binary adapters for ruby are not
well supported under Windows. Using Linux and FreeBSD, never had a
problem.

I'm sure you will find support for the combination and even commercial
support for postgres itself if needs be.

Cheers,
Gary.
Tyler MacDonald (Guest)
on 2009-04-17 22:01
(Received via mailing list)
Bill S. <removed_email_address@domain.invalid> wrote:
> This sounds ridiculous to me, but if I'm missing something, I would love
> to hear some opinions.  Is there an issue with support for
> Ruby+Postgres?

  Not that I've found... I've got a fairly large database schema,
partially
defined in ruby, partially defined as actual PostgreSQL statements, with
referential integrity, triggers, views, etc, and ruby's coping with it
fine.

  For some reason to make a model that queried a view in the database, I
had to add this to the model definition:

  def self.inheritance_column
    "none"
  end

  I can't remember if that was due to the table actually being a view,
or if
there was some other reason for that...  but Ruby and PostgresSQL have
been
playing together very nicely for me, even with a heavily
customized/programmed DB on the PG side.

  Cheers,
    Tyler
Fidel V. (Guest)
on 2009-04-17 22:04
(Received via mailing list)
On Fri, Apr 17, 2009 at 6:59 PM, Gary D. <removed_email_address@domain.invalid> 
wrote:

> My own opinion (no flame wars!) and I know also the opinions of many
> others is that postgres is a superior database in almost every respect,
> particularly the later (8.2+) versions.
>
> In every scenario I have, postgres has outperformed and remained much
> more stable on any meaningful sized databases (1GB to 100GB).
>

Shouldn't agree more.

Fidel.
Robby R. (Guest)
on 2009-04-17 22:18
(Received via mailing list)
PostgreSQL +1


On Fri, Apr 17, 2009 at 11:02 AM, Fidel V.
<removed_email_address@domain.invalid>wrote:

>
> Shouldn't agree more.
>
> Fidel.
>
> >
>


--
Robby R.
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting w/Ruby on Rails

http://planetargon.com/
http://robbyonrails.com/
http://twitter.com/planetargon
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]
James B. (Guest)
on 2009-04-17 22:44
Bill S. wrote:

> This sounds ridiculous to me, but if I'm missing something, I would love
> to hear some opinions.  Is there an issue with support for Ruby+Postgres?

We use Postgres as the backend for everything we run, the sole exception
is our webfax front end which I do not have time to figure out how to
make work with Postgres.  One day perhaps.

The main thing to be aware of with contractors is that the dominant
thinking about DBMS, insofar as web-app developers go, is that it is a
conveniently formatted bit-bucket.  This is very far from the truth but
it is the current paradigm.

ActiveRecord is but a case in point. ORMs frequently make it very
difficult to exploit Postgres's capabilities to any great extent.  There
are plugins to accomplish a few additional things with Postgres through
AR, but most of the features of a full-fledge RDBMS are all but
inaccessible without a lot of SQL strings built into your application.

If your requirements are at all sophisticated in terms of transaction
volume and complexity then you may be better off looking for people who
have worked with the sequel gem and who know Postgres inside out.

Developers with deep knowledge of the DBMS and its inherent capabilities
-- like triggers, functions and stored procedures -- will provide you
with far better results than peole who just know web-apps and the
minimum necessary to get data in and out of the store.
Marnen L. (Guest)
on 2009-04-17 22:59
Bill S. wrote:
> Hello,
>
> We're making a development decision soon to use Ruby to develop a front
> end for our system.  The backend currently runs on Postgresql.

That sounds like good decisions all around.  Will you be using Rails, or
some other Ruby framework?

> Some
> contractors are pushing us to change the backend database to MySQL,
> simply because it's more common to work with Ruby + MySQL.

It's certainly true that more people use mySQL than Postgres.  It's also
true that more people own Windows boxes than Macs.  Popular !=
advisable. :)

OK, that was snarky.  I agree with others on this thread that PostgreSQL
is a better DBMS than mySQL, and no decent developer should have much
problem with it.

> We prefer
> not to support more than one kind of database in house.
>
> We have gotten push back from contractors, who have said, "If it's not
> MySQL, I wont bid on it."

That's silly.  (I'll bid on your PostgreSQL projects any day!)

> I am not a Ruby Developer (IANARD), but I
> would like to know if there is an issue with using Ruby + Postgres.

Not that I know of.  I use them together all the time.

> Someone indicated that Ruby + MySQL play nice together, whereas it's
> problematic to use other kinds of DBs.
>
> This sounds ridiculous to me,

And so it is.  It's not problematic at all; in fact, I recommend it.

> but if I'm missing something, I would love
> to hear some opinions.  Is there an issue with support for
> Ruby+Postgres?

Yes.  The issue is that you won't be able to hire inexperienced
developers who don't want to think about anything but mySQL. :D

>
> Thanks,
> Bill

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
removed_email_address@domain.invalid
Bill S. (Guest)
on 2009-04-18 00:30
Bill S. wrote:
> Hello,
>
> We're making a development decision soon to use Ruby to develop a front
> end for our system.  The backend currently runs on Postgresql.  Some
> contractors are pushing us to change the backend database to MySQL,
> simply because it's more common to work with Ruby + MySQL.  We prefer
> not to support more than one kind of database in house.
>
> We have gotten push back from contractors, who have said, "If it's not
> MySQL, I wont bid on it."  I am not a Ruby Developer (IANARD), but I
> would like to know if there is an issue with using Ruby + Postgres.
> Someone indicated that Ruby + MySQL play nice together, whereas it's
> problematic to use other kinds of DBs.
>
> This sounds ridiculous to me, but if I'm missing something, I would love
> to hear some opinions.  Is there an issue with support for
> Ruby+Postgres?
>
> Thanks,
> Bill

Thank you to everyone who replied.  This is very helpful.

I think we will stick with our current plan, and use Postgresql.  In
general, it makes me uncomfortable when developers refuse to use one
tool or another.  It shouldn't really matter.  It's the architecture
that really counts.  The code design should be modularized, so that any
back-end DB could be used. MySQL and Postgresql shouldn't make a huge
difference to the front-end developer.  (We choose Postgresql for the
back-end for some particular reasons, nothing to do with the
front-end.).
Michael S. (Guest)
on 2009-04-18 02:04
(Received via mailing list)
On Friday 17 April 2009, Bill S. wrote:
> This sounds ridiculous to me, but if I'm missing something, I would
> love to hear some opinions.  Is there an issue with support for
> Ruby+Postgres?

I much prefer PostgreSQL over MySQL. MySQL's interpretation of the SQL
standard(s) has driven me up the wall at times. Does it still force a
default value on every column with a NOT NULL constraint?

PostgreSQL works great with Rails, the support in the core is exactly as
for MySQL. I've encountered the odd extension (plugin, gem, whatever)
that only supports MySQL, but that may rather an indication of the
extension's quality.

Michael

--
Michael S.
mailto:removed_email_address@domain.invalid
http://www.schuerig.de/michael/
Michael S. (Guest)
on 2009-04-18 03:16
(Received via mailing list)
On Saturday 18 April 2009, Michael S. wrote:
> On Friday 17 April 2009, Bill S. wrote:
> > This sounds ridiculous to me, but if I'm missing something, I would
> > love to hear some opinions.  Is there an issue with support for
> > Ruby+Postgres?
>
> I much prefer PostgreSQL over MySQL.

Some other points you might want to check if you compare these two:

- Behavior under concurrent accesses: Transactional isolation, locking.
- Transactional changes to the DB structure.
- Performance with many joins.
- Changing the structure of (large) existing tables.

In my experience, PostgreSQL is better in all of these.

Michael

--
Michael S.
mailto:removed_email_address@domain.invalid
http://www.schuerig.de/michael/
Robert A. (Guest)
on 2009-04-18 04:57
(Received via mailing list)
"Some other points you might want to check if you compare these two:

- Behavior under concurrent accesses: Transactional isolation, locking.
- Transactional changes to the DB structure.
- Performance with many joins.
- Changing the structure of (large) existing tables.

In my experience, PostgreSQL is better in all of these."

Me too.


--
Robert A. Nogueira de Oliveira
_________________________
Tribunal de Justiça do Estado de Sergipe
Graduando em Sistemas de Informação - UNIT
MSN: removed_email_address@domain.invalid

"Ausência de evidência não é evidência de ausência." (Carl Sagan)
Hassan S. (Guest)
on 2009-04-18 05:45
(Received via mailing list)
On Fri, Apr 17, 2009 at 10:43 AM, Bill S.
<removed_email_address@domain.invalid> wrote:

> We have gotten push back from contractors, who have said, "If it's not
> MySQL, I wont bid on it."  I am not a Ruby Developer (IANARD), but I
> would like to know if there is an issue with using Ruby + Postgres.

One thing to consider is that the idea that ActiveRecord just magically
insulates the developer from understanding the underlying database
is wishful thinking, once you get past your basic 'hello world' app.

So if someone knows MySQL well, s/he may not want to put the time
into learning the gotchas of another DB.  I would charge more just to
cover the aggravation of using Postgres's god-awful command line
tools. :-)

But personally, I'm database-agnostic -- right now I'm working on a
JRuby/Rails/Oracle app.

Ultimately, it's "run what ya brung"  :-)

FWIW,
--
Hassan S. ------------------------ removed_email_address@domain.invalid
Danny B. (Guest)
on 2009-04-18 08:41
Robby R. wrote:
> PostgreSQL +1
>

I was scrolling down, waiting for Robby to chime in, then I find this-
c'mon, Robby, I expected more PASSION!  :-P

- Danny
Gary D. (Guest)
on 2009-04-18 11:36
(Received via mailing list)
Hassan S. wrote:
>
> So if someone knows MySQL well, s/he may not want to put the time
> into learning the gotchas of another DB.  I would charge more just to
> cover the aggravation of using Postgres's god-awful command line
> tools. :-)

I Guess you've never found PgAdmin then :)

Cheers,
Gary.
Hassan S. (Guest)
on 2009-04-18 18:01
(Received via mailing list)
On Sat, Apr 18, 2009 at 12:35 AM, Gary D. <removed_email_address@domain.invalid> 
wrote:

>> So if someone knows MySQL well, s/he may not want to put the time
>> into learning the gotchas of another DB.  I would charge more just to
>> cover the aggravation of using Postgres's god-awful command line
>> tools. :-)
>
> I Guess you've never found PgAdmin then :)

I have -- it doesn't appear to be a command-line interface. Or is
there a way to invoke it in a non-GUI mode?

--
Hassan S. ------------------------ removed_email_address@domain.invalid
Cesar D. (Guest)
on 2009-04-18 18:48
(Received via mailing list)
I have been working MySql and Postgres for web applications(I am
talking about Rails applications of course ) and both work well.
From my point of view Postgres is more powerful and I prefer work with
this for my development if there is not any rule which limit me for
some good reason
_______________________________________________
Gnu/Linux count user #416024

Pagina personal : http://www.cesardiaz.com.ar
Mi blog : http://cesarediaz.blogspot.com
Twitter : http://twitter.com/cesarstafe
Github repository: http://github.com/cesarediaz/
Skype: cesarstafe
Gary D. (Guest)
on 2009-04-18 18:51
(Received via mailing list)
Hassan S. wrote:
>
Sorry, I thought you were saying that postgres tools were only
command-line.

What's wrong with psql, pg_dump, pg_restore, pg_ctl etc.?

What does mysql have in the way of command-line tools that postgres
doesn't?

I pretty much always use PgAdmin unless there is no alternative, or when
I need postgres tools in scripts. For ad-hoc management of servers I
normally use PgAdmin remotely.

Cheers,
Gary.
Hassan S. (Guest)
on 2009-04-18 19:34
(Received via mailing list)
On Sat, Apr 18, 2009 at 7:50 AM, Gary D. <removed_email_address@domain.invalid> 
wrote:

> What's wrong with psql, pg_dump, pg_restore, pg_ctl etc.?
>
> What does mysql have in the way of command-line tools that postgres doesn't?

It's not that there are /different/ tools, it's that the postgres
versions
seem awkward, clumsy and unhelpful compared to mysql's.

I'm sure you'd get used to them if you had to, like anything else. But
the experience is not particularly pleasant.

YMMV,
--
Hassan S. ------------------------ removed_email_address@domain.invalid
Michael S. (Guest)
on 2009-04-18 20:28
(Received via mailing list)
On Saturday 18 April 2009, Hassan S. wrote:
> On Sat, Apr 18, 2009 at 7:50 AM, Gary D. <removed_email_address@domain.invalid> wrote:
> > What's wrong with psql, pg_dump, pg_restore, pg_ctl etc.?
> >
> > What does mysql have in the way of command-line tools that postgres
> > doesn't?
>
> It's not that there are /different/ tools, it's that the postgres
> versions seem awkward, clumsy and unhelpful compared to mysql's.

Somehow it's the other way round for me. With the the PostgreSQL command
line tools, notably psql, I have tab completion when I invoke them and
inside the tool itself, where I also get extensive help. I don't seem to
get tab completion with the mysql command. From my experience, your
accusation of the PostgreSQL tools being "awkward, clumsy and unhelpful"
appears to be unsubstantiated.

Michael

--
Michael S.
mailto:removed_email_address@domain.invalid
http://www.schuerig.de/michael/
Hassan S. (Guest)
on 2009-04-18 20:55
(Received via mailing list)
On Sat, Apr 18, 2009 at 9:27 AM, Michael S. 
<removed_email_address@domain.invalid>
wrote:

> From my experience, your
> accusation of the PostgreSQL tools being "awkward, clumsy and unhelpful"
> appears to be unsubstantiated.

Dude, don't get your knickers in a twist.

I made a comment, not an "accusation", and there's hardly anything
to "substantiate" when we're discussing *opinions*.

You like the pg* tools, I don't. YMMV. Go and be happy. Geez...

--
Hassan S. ------------------------ removed_email_address@domain.invalid
John S. (Guest)
on 2009-04-18 22:19
Glad to see that you've settled on Postgresql. I think the contractor
who insists on using MySQL rather than Postgres is probably a bit
immature in their DB experience.

I came to Ruby from a Delphi/Interbase/MSSQL environment and started
using MySQL because it was the default. It was OK but I quickly found
problems with queries that just worked on other DB engines because they
assumed the SQL-92 standard, but they failed on MySQL.

Anyway I've switched to Postgresql because it has much, much, much
better Geographical Information Services (GIS) support. MySQL has
geometry, but only on MyISAM and only flat geometry, not spherical
geometrey, duuuh!

MySQL is OK if you're doing extremely simple stuff and like the herd
mentality around it.
Nick Faraday (Guest)
on 2009-04-19 23:25
(Received via mailing list)
There was just a podcast about this on SD Ruby.

http://sdruby.com/podcast/

I believe it is EP 55
Marnen L. (Guest)
on 2009-04-20 22:17
(Received via mailing list)
Two small quibbles that I thought were just big enough to raise
here...

On Apr 17, 4:30 pm, Bill S. <removed_email_address@domain.invalid> wrote:
> I think we will stick with our current plan, and usePostgresql.  In
> general, it makes me uncomfortable when developers refuse to use one
> tool or another.

It depends on the developer.  Good developers know what they're
talking about, and their preferences can often tell you a lot about a
tool -- and about their development practices -- that you might not
otherwise know.

In other words, if a developer has a *good* reason for refusing to use
something, it may be to your advantage to find out what that reason
is.

>  It shouldn't really matter.  It's the architecture
> that really counts.

Perhaps, but in practice that's not really true -- details that are
computationally trivial can make a huge difference to developer
productivity.  That's why we don't typically develop Web apps in C,
although it can be and has been done.

On Apr 17, 9:44 pm, Hassan S. <removed_email_address@domain.invalid>
wrote:
[...]
> One thing to consider is that the idea that ActiveRecord just magically
> insulates the developer from understanding the underlying database
> is wishful thinking, once you get past your basic 'hello world' app.

Yes, you have to *understand* the DB, but that often does not require
changes to well-written code.  I have written and maintained complex
applications that were deployed on both mySQL and PostgreSQL, often
simultaneously.  ActiveRecord really *does* insulate the developer
from a lot of DB-specific stuff -- if the developer is smart and
writes DB-neutrally.  (I just took over maintenance of an app where
the developer didn't do that...)

And part of being "smart" is understanding the underlying DB well
enough to know what's portable and what isn't.

>
> So if someone knows MySQL well, s/he may not want to put the time
> into learning the gotchas of another DB.  I would charge more just to
> cover the aggravation of using Postgres's god-awful command line
> tools. :-)

I never use the command-line tools, either with PostgreSQL or mySQL.
I don't find either set to be very easy to use...that's what graphical
admin programs are for.

(Maybe if I were a DBA, things would be different.  But I just don't
use the command-line tools often enough to remember syntax between
uses.)

Best,
--
Marnen Laibow-Koser
removed_email_address@domain.invalid
http://www.marnen.org
Hassan S. (Guest)
on 2009-04-20 22:42
(Received via mailing list)
On Mon, Apr 20, 2009 at 11:16 AM, Marnen Laibow-Koser
<removed_email_address@domain.invalid> wrote:

> Yes, you have to *understand* the DB, but that often does not require
> changes to well-written code.  I have written and maintained complex
> applications that were deployed on both mySQL and PostgreSQL, often
> simultaneously.  ActiveRecord really *does* insulate the developer
> from a lot of DB-specific stuff -- if the developer is smart and
> writes DB-neutrally.

When you use *standard AR associations* -- no custom SQL at all --
and it runs on one DB and fails on another, I'd say you need to know
a little more about those DBs. Wouldn't you?  :-)

--
Hassan S. ------------------------ removed_email_address@domain.invalid
TheRailsWayOrTheHighway (Guest)
on 2009-04-20 23:39
(Received via mailing list)
Here's a quote from the February issue of Linux Journal (p69) that
might be of interest to you:  "I use PostgreSQL as my database, as
I've decided to give PostgreSQL a go having read Reuven Lerner's
excellent series of articles comparing PostgreSQL to MySQL (see the
April, May and June 2007 issues of LJ.)"

Especially significant, now that Oracle will own MySQL.
This topic is locked and can not be replied to.