sql性能分析


/*
DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE
*/
SET STATISTICS IO ON
SET STATISTICS TIME ON

 SELECT TOP 10 *
 FROM UserTraces AS ut1
 WHERE ActionID<>2
  AND NOT EXISTS(
   SELECT 1
   FROM UserTraces
   WHERE ExtensionID1=ut1.ExtensionID1 AND ActionID<>2 AND CreateDate>ut1.CreateDate
   )
 ORDER BY CreateDate DESC

 SELECT TOP 10 *
  FROM UserTraces AS t1
   Where EXISTS
   (
      SELECT *
      FROM UserTraces AS t2
      WHERE ActionID<>2
      GROUP BY ExtensionID1
      HAVING ExtensionID1 = t1.ExtensionID1
    and max(CreateDate) = t1.CreateDate
   )
   ORDER BY CreateDate DESC

SET STATISTICS TIME OFF
SET STATISTICS IO OFF

 

posted on 2008-05-30 14:24  Randy0528  阅读(396)  评论(0编辑  收藏  举报