Consider a simple query like this:
SELECT * FROM DATA
JOIN
(
SELECT * FROM DATA
)TEMPORARY_DATA
ON TEMPORARY_DATA.DATA_IDN = DATA.DATA_IDN
What is the performance of this? Is it O(n2)
because TEMPORARY_DATA
doesn't have indexes as opposed to normal tables. Normal joins I think happens in O(nlogn)
time because it is indexed right?
Does this change if the inner query is slightly complex and so direct? I mean is it possible the optimized it not able to guess that it is not the indexed DATA table!
I am newbie to these things, please let me know if this belongs to some other place on the SO Network.