http://qs321.pair.com?node_id=688461


in reply to A profiling surprise ...

Just a general comment re my experiences with similar issues.
I discovered that just because a DB has built-in fns to do handy stuff like eg sum(), group by for example, it doesn't necessarily mean they are efficiently coded.
I actually improved a prog by order of magnitude iirc, by in fact doing relatively simple SELECTS instead, and doing those fns in Perl.
Its worth testing stuff like that instead of assuming.
I'd also go with checking/setting indexes as advised above.