Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

pre2 and pre4 with rails3 do count for total even if given :total_entries #143

inspire22 opened this Issue Jul 29, 2011 · 3 comments


None yet
3 participants

Loading development environment (Rails 3.0.9)
is=Item.paginate :page => 1, :per_page => 10, :total_entries => 100

Item Load (33.6ms) SELECT items.* FROM items LIMIT 10 OFFSET 0
SQL (11378.1ms) SELECT COUNT(*) FROM items

This is especially a problem with innodb, as count(*) is very slow.

Problem appears to be in active_record.rb the total_entries method does @total_entries ||=. But it's not set via the paginate call somehow.

I can't quire wrap my head around which is the Collection object's instance variables and which are in the active-record relation, so I can't quite follow how it should work.

Aah, perhaps it's because in the paginate submodule you set total_entries = wp_parse rather than self.total_entries = wp_parse? Or @total_entries. Hmm, hacking it and using @total_entries instead still doesn't show up with total_entries() is called.


mislav commented Jul 29, 2011

I will look into this. I thought I supported this feature, but might be that I made a mistake. Thanks for reporting

fhwang commented Jul 31, 2011

For what it's worth, I'm seeing this in pre4 but not pre2.

@mislav mislav closed this in 5d26795 Aug 2, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment