drnic/composite_primary_keys — pull request #99 by codeodor (2012-04-16 16:14:28+00:00)
Title: Fixes Issue 98 for me

After some further research on issue 98 (https://github.com/drnic/composite_primary_keys/issues/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. =)