ProtocolPirate
Programmer
if I run this query it takes about 10 seconds:
SELECT s.Name
FROM (
SELECT ChargeNumber, RefPhyCode FROM Posting_Wilshire
UNION ALL
SELECT ChargeNumber, RefPhyCode FROM Posting_Brea
) AS a
INNER JOIN Servloc s ON s.Id=a.RefPhyCode
But when I added on line too it:
INNER JOIN Daysheet d ON d.ChargeNum=a.ChargeNumber
All of a sudden it takes hours. There IS an index on Daysheet.ChargeNum, and as long as I don't have queries that start from a virtual table made from the UNION of posting tables, I get great response time from any kind of query on Daysheet, no matter how stacked the JOIN statements are too other tables.
Why does adding this one line, which doesn't produce anymore rows of data, make the execution jump up by several orders of magnitude?
SELECT s.Name
FROM (
SELECT ChargeNumber, RefPhyCode FROM Posting_Wilshire
UNION ALL
SELECT ChargeNumber, RefPhyCode FROM Posting_Brea
) AS a
INNER JOIN Servloc s ON s.Id=a.RefPhyCode
But when I added on line too it:
INNER JOIN Daysheet d ON d.ChargeNum=a.ChargeNumber
All of a sudden it takes hours. There IS an index on Daysheet.ChargeNum, and as long as I don't have queries that start from a virtual table made from the UNION of posting tables, I get great response time from any kind of query on Daysheet, no matter how stacked the JOIN statements are too other tables.
Why does adding this one line, which doesn't produce anymore rows of data, make the execution jump up by several orders of magnitude?