iamtoc
iamtoc

Reputation: 1709

Ruby Rails 2.3.x What is the theory behind pagination?

I have a users table with 3000 user records. Pagination works fine, but when looking at the firebug timeline, it states the content size of the download is 2.37MB with 9.62s time to download. Pagination works fine, but I was hoping it only downloaded just the first 25 records and provided links to the additional available pages. I have tried sunspot, thinking-sphinxs, the rails find_in_batches, a straight up :limit => 25, etc.

If pagination splits up the recordset and displays 25 records per page, then why does it appear to still download the entire table? Does not this defeat the theory behind pagination or what am I missing?

@users = User.all(:conditions => ["client_id = ?", current_user.client_id]).paginate(:page => params[:page], :per_page => 25)

Obviously, the goal here is to load my page within a second or two, as apposed to 10 or 12 seconds. Is there a better way to approach this?

Upvotes: 1

Views: 97

Answers (1)

Thilo
Thilo

Reputation: 17735

You don't mention the gem you use for pagination, but if it's any of the usual suspects (or still built into Rails 2.3 - I don't recall), it should in fact use a LIMIT to query only the relevant records. Your slow page load time is most likely due to something else. Take a look at your development log to see the actual query.

Upvotes: 1

Related Questions