Change the script so it actually build a page rather than making it on the fly.
Log clicks and impressions in a memory table and parse the clicks / impressions every few minutes.
The more load you remove from mysql the more complex sorting you'll be able to do (more popular pix per referring domain, most productive design per domain etc)
__________________
I buy plugs
Skype: Due_Global
/Due
|