You will have to look at all the components involved in your portal. In particular look at network connectivity. If your query is very long and complex this needs to be transmitted from the portal to the database server. The data will also need to be sent back. I had written a small article about this PHP & Mysql – architecture « IT Integrated Business Solutions
If you are satisfied that your network is working fine then look at your application servers ability to process the data and respond to the browser request.