Fulltext search adventures with Postgresql
So yeah, we've been using Postgresql on Funadvice just after we made the big switch to Ruby on Rails more than a year ago now. We're still a small site coming up quickly to a million uniques per month and we're holding up pretty well.
I know tons of sites use MySQL successfully, but for us, there was some data corruption, mysterious MySQL load flareups and some slowdowns in some key queries. The switch to Postgresql did it for us, and to be honest i have not had to think about the database in the past year.
Now we've tried different kinds of search engines over the past year too. At first, ferret worked well with acts_as_ferret, but the index just kept crashing and throwing some nasty errors. Then we went to swish-e which gave us perfect results, but keeping the index rebuilt daily was beginning to become a massive chore (the index has to be rebuilt completely each time).
Finally we tried Tsearch2 which had stemming out of the box and truly remarkable speed over a full text corpus of over 200,000 records.
Now I could do stuff like this:
tquery = 'photos of emo'
@photos = Photo.find(:all, :conditions => ['fti @@ to_tsquery(?)', tquery.gsub(/[ ]+/, '').strip ], :order => 'id DESC', :limit => 10)
And it wraps great into native pagination and seamlessly into Active Record.
No doubt it takes a little setting up the database fields and so forth first, and these addon Postgresql types are not going to fit into migrations either. But this works for us, and so far seems to be nicely scaleable with what we have.
Give Tsearch a whirl if you're already using Postgresql, or even if you're not. You'll be glad you did.