http://www.perlmonks.org?node_id=688218


in reply to A profiling surprise ...

There is an art to making DB-bound applications run efficiently. The short of it is "Index, index, index".

Now, another solution would be to construct your data such that the hit pileups can be detected as part of a SQL query. This isn't as hard as it sounds. Take a look at the MySQL function COALESCE().


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?