How many results does that recordset return? It looks like you may be trying to load too much data into the page at one time. What are you doing with that recordset? Do you need all of the rows?
Run that query in php myadmin... how many rows does it return? I think you might need to optimize that query or at least limit the number of results to use it on a web page.