블로그 이미지
010-9967-0955 보미아빠

카테고리

보미아빠, 석이 (500)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total
Today
Yesterday

달력

« » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

공지사항

최근에 올라온 글

http://cafe.naver.com/sqlmvp/3487

 

dbcc freeproccache
go

drop table tblx
go

create table tblx
(idx int
,a int
,b int)
go

create clustered index nc_tblx_01 on tblx (idx)
create nonclustered index nc_tblx_02 on tblx (a)

--dbcc show_statistics (tblx, nc_tblx_01)
--dbcc show_statistics (tblx, nc_tblx_02)

if OBJECT_ID ('usp_cluster') is null
exec ('create proc usp_cluster as select 1 ')
go
if OBJECT_ID ('usp_covered') is null
exec ('create proc usp_covered as select 1 ')
go
if OBJECT_ID ('usp_none_covered') is null
exec ('create proc usp_none_covered as select 1 ')
go

alter proc usp_cluster
@a int
as
select * from tblx where idx = @a
go

alter proc usp_covered
@a int
as
select a from tblx where a = @a
go

alter proc usp_none_covered
@a int
as
select * from tblx where a = @a
go

set nocount on
declare @init int = 0
while (@init < 10000) begin
insert into tblx values (1,@init,1)
set @init += 1
end
go

exec dbo.usp_cluster 1
go 10
exec dbo.usp_covered 1
go 10
exec dbo.usp_none_covered 1
go 10

select refcounts, usecounts, plan_generation_num, text, *
from sys.dm_exec_query_stats a
cross apply sys.dm_exec_sql_text (a.sql_handle) b
left outer join sys.dm_exec_cached_plans c
on a.plan_handle = c.plan_handle
where text like '%tblx%'
and text not like '%sys.dm%'
and text not like '%insert%'
go

set nocount on
declare @init int = 0
while (@init < 10000) begin
insert into tblx values (1,@init,1)
set @init += 1
end
go

-- 여기서 부터 프로파일링 잡을것

exec dbo.usp_cluster 1
go
exec dbo.usp_covered 1
go
exec dbo.usp_none_covered 1
go

select refcounts, usecounts, plan_generation_num, text, *
from sys.dm_exec_query_stats a
cross apply sys.dm_exec_sql_text (a.sql_handle) b
left outer join sys.dm_exec_cached_plans c
on a.plan_handle = c.plan_handle
where text like '%tblx%'
and text not like '%sys.dm%'
and text not like '%insert%'
go

프로시저가 플랜을 재컴파일이 일어남을 잡는 방법 및 재컴파일시 결과

clustered index 만 재컴파일 일어나도록 했고, 나머지는 돌리지 않은 결과 입니다.

 

 

 

Posted by 보미아빠
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함