sql語句最佳化與時間成本(downmoon)

來源:互聯網
上載者:User

--
增加分析


set
 
statistics
  io 
on


go


set
 
statistics
  time 
on


go


set
 nocount 
on
 

go


set
 showplan_text 
on


go


set
 showplan_All 
on


go


--
--取消分析


--
--set statistics  io off


--
--go


--
--set statistics  time off


--
--go


--
--set nocount off 


--
--go


--
--set showplan_text off


--
--go


--
--set showplan_All off


--
--go


--
執行語句




declare
 
@bt
 
datetime
 

set
 
@bt
=
getdate
()

select
 
*
 
from
 productinfo 

select
 
[
語句執行花費時間(毫秒)
]
=
datediff
(ss,
@bt
,
getdate
())


SELECT
 
[
P_ID
]
      ,
[
P_Name
]
      ,
[
P_Key
]
      ,
[
P_Order
]


      ,
[
P_Cate
]
      ,
[
P_SysCate
]
      ,
[
P_C_ID
]
      ,
[
P_C_Name
]


      ,
[
P_C_Order
]
      ,
[
P_C_Contact
]
      ,
[
P_C_Address
]
      ,
[
P_C_Tel
]


      ,
[
P_C_Email
]
      ,
[
P_C_Fax
]
      ,
[
P_C_Web
]
      ,
[
P_TopTime
]


      ,
[
P_InsertTime
]
      ,
[
P_ModifyTime
]
      ,
[
P_BigImage
]
      ,
[
P_SmallImage
]


      ,
[
P_User
]
      ,
[
P_CheckState
]
      ,
[
P_CheckInfo
]
      ,
[
P_Price
]


      ,
[
P_OtherState
]


  
FROM
 
[
ProductInfo
]



--
取時間的格式。


--
 select   CONVERT(varchar(10),   getDate(),120)   --不要時間2002-1-1  


--
  select   convert(char(8),getdate(),112)   ----20020101  


--
  select   convert(char(8),getdate(),108)     ---06:05:05 






 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.