Performance difference with subqueries
I've ported a data set from SQL Server (2000) to MySQL (5.0.26, OS X). I'm having drastic issues with performance on queries that work fine on SQL Server. Example:
QUERY1:
EXPLAIN SELECT tdate FROM dlog_90_view AS t
LEFT JOIN products AS p ON t.upc = p.upc
LEFT JOIN departments AS d ON d.dept_no = t.department
LEFT JOIN MasterSuperDepts AS s ON t.department = s.dept_ID
LEFT JOIN prodExtra AS x ON t.upc = x.upc
WHERE t.department BETWEEN 1 AND 1
AND tDate >= '2011-09-30 00:00:00'
AND tDate <= '2011-10-01 23:59:59';
EXECUTION TIME: 0.05 seconds
QUERY2:
EXPLAIN SELECT tdate FROM (SELECT * FROM dlog_90_view) AS t
LEFT JOIN products AS p ON t.upc = p.upc
LEFT JOIN departments AS d ON d.dept_no = t.department
LEFT JOIN MasterSuperDepts AS s ON t.department = s.dept_ID
LEFT JOIN prodExtra AS x ON t.upc = x.upc
WHERE t.department BETWEEN 1 AND 1
AND tDate >= '2011-09-30 00:00:00'
AND tDate <= '2011-10-01 23:59:59';
EXECUTION TIME: 50.76 seconds
I realize the second query isn't really sensible. I first noticed the problem in queries where the subquery is a UNION ALL of two tables. I initially thought the UNION was the source of my problems, but simply having a subquery seems to have far more impact on performance than the size of the rowset. The table underlying dlog_90_view has no indexes or keys.
I can post the EXPLAIN output if it would be helpful (form etiquette: should these be paste-bin'd? Wrapped in some BB tags)?
Subject
Written By
Posted
Performance difference with subqueries
January 25, 2012 11:33AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.