wanttoscript
IS-IT--Management
I am new to MySQL, and am in the process of migrating an ACCESS database to MySQL/PHP. I am having some big performance issues!
I have many queries that rely on three tables:
i. employee_info (describes a hierarchy of users)
ii. call_info (data describing phone calls)
iii. answers (answers to questions on each call)
My queries in ACCESS look something like:
SELECT Count(answers.answer) AS num_answers
FROM (call_info LEFT JOIN answers ON call_info.call_id = answers.call_id) INNER JOIN employee_info ON call_info.employee_number = employee_info.employee_number
WHERE (((employee_info.level3)=2) AND ((call_info.call_date)>=#3/1/2003# And ((call_info.call_date)<=#4/1/2003#));
This will typically run on 200,000 calls in less than 2 seconds!
When I convert directly to MySQL I try
SELECT Count(answers.answer) AS num_answers
FROM (call_info LEFT JOIN answers ON call_info.call_id = answers.call_id) INNER JOIN employee_info ON call_info.employee_number = employee_info.employee_number
WHERE (((employee_info.level3)=2) AND ((call_info.call_date)>="2003-03-01" And ((call_info.call_date)<="2003-04-01");
THIS TAKES OVER 2 minutes to run .... I am sure this has to do with how I JOIN the tables, but I don't know how to speed this up!
Any help/ guidance would be most appreciated.
I have many queries that rely on three tables:
i. employee_info (describes a hierarchy of users)
ii. call_info (data describing phone calls)
iii. answers (answers to questions on each call)
My queries in ACCESS look something like:
SELECT Count(answers.answer) AS num_answers
FROM (call_info LEFT JOIN answers ON call_info.call_id = answers.call_id) INNER JOIN employee_info ON call_info.employee_number = employee_info.employee_number
WHERE (((employee_info.level3)=2) AND ((call_info.call_date)>=#3/1/2003# And ((call_info.call_date)<=#4/1/2003#));
This will typically run on 200,000 calls in less than 2 seconds!
When I convert directly to MySQL I try
SELECT Count(answers.answer) AS num_answers
FROM (call_info LEFT JOIN answers ON call_info.call_id = answers.call_id) INNER JOIN employee_info ON call_info.employee_number = employee_info.employee_number
WHERE (((employee_info.level3)=2) AND ((call_info.call_date)>="2003-03-01" And ((call_info.call_date)<="2003-04-01");
THIS TAKES OVER 2 minutes to run .... I am sure this has to do with how I JOIN the tables, but I don't know how to speed this up!
Any help/ guidance would be most appreciated.