27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This chapter covers<br />

� Implementing pagination for resources with the<br />

Kaminari gem<br />

� Improving database query speeds with Active Record<br />

features<br />

� Caching pages and fragments of pages<br />

� Using the Delayed Job gem with background workers<br />

Basic performance<br />

enhancements<br />

When an application is written, it may be done in such a way that it will not perform<br />

ideally. A common situation is that an application with a small database will perform<br />

quickly because there is less data to retrieve, but starts to slow as the database<br />

grows larger. This problem can be fixed in many different ways.<br />

The first way is to limit the amount of data retrieved in any one call to a fixed<br />

limit, a process known as pagination. At the moment, for example, you’re not limiting<br />

the number of tickets shown in the show action of the ProjectsController. The<br />

more tickets that get added to a project, the slower the page that shows this data is<br />

going to perform because it will have to retrieve more data from the database and<br />

render it out to the page. By breaking the data down into a set of pages, you can<br />

434

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!