I suspect that you are trying to optimize the wrong end of the problem. My experience in writing database apps in perl has been that the time spent in the database executing the queries, and fetching the data far outweigh the CPU time of the perl subroutines.