Skeeve is absolutely correct. Some further items:
- Add indices to the tables. Indexing isn't always easy and you should read MySQL's manual or ask your DBA to help you.
- ANALYZE and OPTIMIZE your tables. This will provide anywhere from 0% to 10%.
- Improve your DBI usage. Use bind params and fetch() instead of fetchrow_array(). That can give you 0% to 40%, or more.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?