Jason Watkins’s Weblog

PostgreSQL will finally come (replication) batteries included

Posted in Uncategorized by jasonwatkinspdx on June 3rd, 2008

Personally I’d say this is about 4 years overdue. While there are replication options for PostgreSQL, no one seems to particularly care. The lack of simple built in replication is the second most common reason I see for MySQL adoption over PostgreSQL. The most common is speed, despite results that seem to indicate that the two are roughly at parity.

I think this is a great move that will really boost PostgreSQL adoption.

Force index with active record find

Posted in Blog by jasonwatkinspdx on March 17th, 2008

A small useful tip:

Mysql’s query planner occasionally has trouble picking the right index. I’ve found that normally if you try variations long enough, eventually you find a way to do the right thing. Recently however I ran into one I couldn’t coax.

No big deal you say, after all, that’s what find_by_sql is for no? Only problem is, the query in question was inside a with_scope block, and I really didn’t want to have to find and hardcode sql finders for any variations used by callers. Thankfully, the :from option on find can rescue us: just go ahead and include the force index clause. It’s slightly gross imho, but it works, and might save you some manual sql building.