Not that I know of, but I only know what the Apache folks said on that bug report. Try running your query from the command line. The bug report suggests that the timeout isn't actually because your script takes 300sec to execute, but because the volume of output it produces breaks Apache's attempts to keep up with it.
I'd suggest running your script on the command line to determine:
- Does it really take >5 minutes to run?
- How much output is sent to STDOUT/STDERR?
That should give you a better idea of what you can reduce (time or output).