Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
lloydz1
Starting Member
1 Post |
Posted - 2013-06-28 : 07:43:00
|
I have a small problem that I cannot understand, I am currently studying to undertake exam 70-461 and have been applying some of what I have learned to the workplace. However one thing seems to go against what I have learnt which is the order by statement; According to the Logical Query Processing Phases the 'From' statement is the first to execute followed by the 'Where', 'Group By', 'Having', 'Select' and then finally the 'Order By' . However, when I execute a complex Select statement with multiple joins and no Order By it runs extremely fast, When I apply the Order By it takes in excess of 90 Seconds to run. I then inserted the values into a temporary table without the order by and selected the Results from that temporary table with the order by and the statement will run in less than a second. This is confusing in my mind as the Select is the last thing to run before the Order By and therefore the result of the select phase is the same hence the order by should run in the same time on both queries.I have toyed with the idea of removing the order by to make the result Relational but the end user requires that it should be ordered set of results.BRLloydz1 |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-06-28 : 08:36:36
|
In your original query where do you have the order by clause? (are you sorting on the final data set or are you sorting the intermediate data sets?) |
|
|
|
|
|