Options for helping you are pretty limited until you post the info asked for.
- EXPLAIN of query
- Table structure
To be honest though, if you're dealing with a large number of records on a shared host, it's reasonable that a query would take 1 second. Figure out whether it's the query itself or the while() loop that's hogging CPU.
If it's the latter the only choice really is to slow the loop down by waiting with usleep();