I have some tables, with the rows like below:

mysql> select count(*) from job_main;
+----------+
| count(*) |
+----------+
|     6835 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from company_main;
+----------+
| count(*) |
+----------+
|     8177 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from job_working_place;
+----------+
| count(*) |
+----------+
|     8521 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from job_terms;
+----------+
| count(*) |
+----------+
|    10037 |
+----------+
1 row in set (0.00 sec)

When I tried to query using:

SELECT COUNT(*) FROM job_main 
LEFT JOIN company_main ON company_main.id = job_main.company_main_id 
LEFT JOIN job_working_place ON job_working_place.job_main_id = job_main.id
LEFT JOIN job_terms ON job_terms.job_main_id = job_main.id
WHERE job_main.permission = 'allow' 
AND job_main.job_type_code = '10'
AND job_working_place.working_place_code = '1'
AND job_terms.employment_code = '1'
AND company_main.company_type_code = '1'
AND job_terms.salary_type = 'hourly'
AND job_terms.salary_amount_from >= '800';

It was so slow. I have index on every column I wrote above. Is it the
right way to query? Please help, and thank you very much.

--bk



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to