MTG/freesound — pull request #577 by alastair (2014-03-05 13:27:34+00:00)
Title: Provide explicit list lengths for pagination

This patch creates a new paginator that knows about the length of the list that it's paginating. I'm currently using it for lists of people who downloaded sounds and packs.
The result of the patch is that we no longer perform a query such as `select count(*) from sounds_download where sound_id = x`. This speeds up the page display a lot because we don't have to count the table each time we show the page.
There may be some small deviation between the actual number of rows in the table and the counts in the sound/pack objects. We need to coordinate with #560 to ensure that it's always correct.

It's more difficult to use this for "sounds that this person downloaded", since we don't have a field `Profile.num_sounds_downloaded`. We should keep an eye on the statistics for these `count(*)` queries to see if it makes sense to add this field. As `sounds_download` keeps on increasing, it may be a good idea to do so.