Quantcast
Channel: MySQL Forums - Microsoft SQL Server
Viewing all articles
Browse latest Browse all 686

Performance difference with subqueries (no replies)

$
0
0
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)?

Viewing all articles
Browse latest Browse all 686

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>