sql语句优化与时间成本(downmoon)


-- 增加分析
set statistics io on
go
set statistics time on
go
set nocount on
go
set showplan_text on
go
set showplan_All on
go
-- --取消分析
--
--setstatisticsiooff
--
--go
--
--setstatisticstimeoff
--
--go
--
--setnocountoff
--
--go
--
--setshowplan_textoff
--
--go
--
--setshowplan_Alloff
--
--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 ]

-- 取时间的格式。
--
 selectCONVERT(varchar(10),getDate(),120)--不要时间2002-1-1
--
selectconvert(char(8),getdate(),112)----20020101
--
selectconvert(char(8),getdate(),108)---06:05:05




你可能感兴趣的:(sql语句)