I’m currently with a client using a heroku database with a row limit and we have a big table that logs activities, so after trying some solutions I found out that I can use a different connection for a single model.
Will it affect performance by a lot? I think I’m going to create a micro instance with postgres with just this table.
No, having more than one database connection shouldn’t affect performance. It might use slightly more memory per worker process, but probably not by enough to be a concern.
The way I set up a second database connection, was to use another stanza in database.yml. In addition to development and production sections, there can be an ‘other_db’ connection that you reference in the model that uses it. If you wind up having several models use the other connection, you may want to create one ‘superclass’ model that inherits from ActiveRecord::Base and just has the establish_connection line, and have the actual models inherit from that one. That way you don’t keep repeating the establish_connection line.