The first thing you might want to look into is indexing any columns which participate in the query. For example, if you your query is always testing the value of a column FirstName
, you might want to index that.
If you provide a DDL (Data Definition Lanaguage) script or a description of the tables, as well as the queries that are taking so long, we might be able to provide better tips for indexing.
If you've already tuned as much as you can and you still get timeouts, you might want to see if you can increase the transaction timeout limit. I don't know enough about your server setup to give details, but that sort of thing is usually possible.
UPDATE
If your query is:
SELECT toemail,toname FROM email_sent WHERE companyid = '$member[companyid]'
My first question is: do you have an index on companyid
and if not, does creating one improve performance?