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.

# :include example
#
@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.

Tagged with: