1.未指定order by子句时,查询结果受到检索时使用到的索引影响;
SELECT TOP 10000 IDENTITY(INT ,1,1) AS Pkid ,o.* INTO tempTable FROM sys.objects o,sys.[columns] c
CREATE CLUSTERED INDEX ixuc_pkid ON tempTable(pkid ASC)
--CREATE CLUSTERED INDEX ixuc_pkid ON tempTable(pkid DESC)
DROP INDEX dbo.tempTable.ixuc_pkid
(1) SELECT * FROM tempTable tt
CREATE INDEX cxde_objid ON dbo.tempTable(OBJECT_ID)
(2) SELECT * FROM tempTable tt ORDER BY tt.OBJECT_ID
DROP INDEX dbo.tempTable.ixuc_pkid
(3) SELECT * FROM tempTable tt ORDER BY tt.OBJECT_ID
通过CTRL+L查看(1)(2)(3)查询开销验证以上结论
2.指定order by子句时,除非受到