Hi.
I've got a rather large problem with MySQL. I'm trying to do a query over several tables, and the query is taking 18 seconds to execute on a 600Mhz sever. For reference, here's the query string....
SELECT tcons.title, tcons.first_name, tcons.last_name, tcons.cons_first4, tcons.cons_spec_code, tcons.cons_seq, thosp.town, thsc.nhs_private, ttrust.region_code
FROM ttrust (INNER JOIN thosp (INNER JOIN tcons INNER JOIN thsc ON tcons.cons_first4 = thsc.cons_four AND tcons.cons_spec_code = thsc.cons_spec AND tcons.cons_seq = thsc.cons_seq) ON thosp.hosp_trust_code = thsc.hosp_trust_code AND thosp.hosp_seq = thsc.hosp_seq)
ON ttrust.trust_code = thosp.hosp_trust_code
WHERE ttrust.region_code = 'LN';
The table thsc has about 40,000 records, tcons about 30,000, thosp about 4000 and only a couple of hundred in ttrust, and the resulting query has about 7500 rows in it.
Is there any way that i can speed up these queries? I havent defined any forign keys on the tables, or the table type - does this matter? I really hope this isn't a limitation of MySQL, cos that would screw up my plans for my website!
Please don't let it be true!
Thanks
Robin