Why is ruby build in pagination bad?

Im trying to understand why the ruby pagination is slow and bad so that
I can write a good one of my own.

From my understanding, the ruby paginator, just takes the full results
set and display only the portion that you want it to display.

Yep. Imagine you have a table with a million rows of data (with a lot of
text columns). And you want to page through it ten at a time. Why you'd
do this I dunno, but let's just pretend.

To display rows 1-10 Rails is going to return *all* million rows, create
objects for all of them, then hand you back the first 10. So it's doing
this in SQL: SELECT * FROM big_table

If you create your own pager you can make this a lot more efficient by
doing something like this: SELECT * FROM big_table LIMIT 10 OFFSET 0

And you're only returning 10 rows hwich is going to be a lot faster than
returning 1 million...


also be sure to check out paginating_find
I like the way it overloads the regular find method.