The biggest performance increases we were getting was when we could push some sort of comparison or logic from PHP into the SQL query.What we did was re-write all of the application except the parts that actually printed HTML to the page in C. We made that library into a php extension, which we added to our php installation.