민석형 자료를 보면서 정리.
use test go set statistics time on go select cast(CAST ( getdate() as float)as int) -- (현재) 날짜값을 정수형으로 반환 select cast(CAST ( getdate() -1 as float)as int) -- (현재) 날짜값을 정수형으로 반환 -- 대부분 처리 방법 select convert(char(8), d, 112) ,COUNT(*) from dbo.tblx where d between '2012-09-11' and '2012-09-11 23:59:59' group by convert(char(8), d, 112) order by 1 go -- #. 빠른 처리 방법 SELECT CONVERT(datetime,cast(CAST (d as float)as int)) ,COUNT(*) FROM dbo.tblx WITH(NOLOCK) where d between '2012-09-11' and '2012-09-11 23:59:59' GROUP BY cast(CAST (d as float)as int) order by 1 option (maxdop 1) --SQL Server 구문 분석 및 컴파일 시간: -- CPU 시간 = 0ms, 경과 시간 = 5ms. --(1개 행이 영향을 받음) -- SQL Server 실행 시간: -- CPU 시간 = 889밀리초, 경과 시간 = 878밀리초 --(1개 행이 영향을 받음) -- SQL Server 실행 시간: -- CPU 시간 = 281밀리초, 경과 시간 = 293밀리초
'Transact-SQL' 카테고리의 다른 글
relog 사용 방법 (0) | 2012.09.28 |
---|---|
UPDLOCK (0) | 2012.09.20 |
How to Recycle SQL Server error logs – 5 Types of logs (1) | 2012.09.03 |
ORIGINAL_LOGIN() 와 SUSER_SNAME() 차이 (0) | 2012.07.30 |
쥑이는 SCRIPT (0) | 2012.06.28 |