Reduce database connections using :include
When displaying a list that requires information from several tables in the database, you can sometimes end up with three or more database queries per list row. Depending on the situation, this may not be a problem. However, it is possible to join the tables in one large SQL query using the :include option.
@requests = Request.find(:all, :include => [:department, :status])
Using the :include option may improve performance. However, it will likely use more server memory and could potentially return a lot of data through the joins that may not even be used.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
No comments yet.
Leave a comment