Fixes Issue 98 for me #99
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After some further research on issue 98 (#98), it looks like it's just doing the same thing Rails' version is doing, but adding some special cases for CPK.
However, I didn't find out how/why Rails was not using the subquery.
Instead, I just created a case like "if we're only selecting 1 column, there's no need for the subquery, so don't use it"
Not sure if you're interested in including that or not, but in case you are, I've submitted this pull request.
I don't like to hack around this kind of thing -- it makes the code uglier and harder to follow -- but if everyone else is seeing 5-10 seconds to count records using the subquery vs. almost instantaneous results without the subquery, then I guess it's useful.
If it's just me, well then I guess I'll have to monkey patch it in my project. =)