I've got a pagination with about 500000 items, and I don't know if it
will be slow. I need only the first 1000, so what I'm trying to do is
@item_pages, @items = paginate(:products, :order => "title", :per_page
=> 15, :limit => 1000)
But paginate seems to have no limit option. Will the pagination be
fast without this option?
I've got a pagination with about 500000 items, and I don't know if it
will be slow. I need only the first 1000, so what I'm trying to do is
@item_pages, @items = paginate(:products, :order => "title", :per_page
=> 15, :limit => 1000)
The built in rails pagination will explode with that many items. I
strongly recomment find_by_sql with a :limit parameter.
The built-in paginator is a known performance and scalability bottleneck
and is likely to be removed from the Rails core in upcoming releases.
Luckily, there's a couple of very good plugins out there that've tackled
the issue: paginating_find [1] and will_paginate [2].
It's gone in edge rails, though there's a plugin for backwards
compatibility purposes.
thanks all for the pagination tips, and thanks too for pointing out
the RailsCasts. For some reason I had not picked up on these yet,
but have just been and had a look and they are really cool.