If its faster sometimes then it's probably because when you run the same query twice i.e. first time slow but second time fast due to caching.
SELECT mantis_bug_table. * , sadb.business_name AS service_agent_name
FROM mantis_bug_table
LEFT JOIN national_sam.asgeodata AS sadb ON mantis_bug_table.service_agent = sadb.rs_id
ORDER BY mantis_bug_table.last_updated DESC , mantis_bug_table.date_submitted DESC
LIMIT 100 , 50
You don't need LEFT JOIN, so if you remove join from the above sql, then you would get the same result as with original sql, try:
SELECT
mantis_bug_table.*,
FROM
mantis_bug_table
ORDER BY mantis_bug_table.last_updated DESC,
mantis_bug_table.date_submitted DESC
LIMIT 100, 50
So, you probably need INNER JOIN
SELECT
mantis_bug_table.*,
sadb.business_name AS service_agent_name
FROM
mantis_bug_table
INNER JOIN national_sam.asgeodata AS sadb
ON mantis_bug_table.service_agent = sadb.rs_id
ORDER BY mantis_bug_table.last_updated DESC,
mantis_bug_table.date_submitted DESC
LIMIT 100, 50
Edited 1 time(s). Last edit at 07/26/2012 04:02AM by Aftab Khan.