Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
inspire22 opened this issue Jul 29, 2011 · 3 comments
Closed

Comments

@inspire22
Copy link

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.

@inspire22
Copy link
Author

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
Copy link
Owner

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
Copy link

fhwang commented Jul 31, 2011

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

@mislav mislav closed this as completed in 5d26795 Aug 2, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants