반응형
- /**********************************************************************************************
-- Title : [2k5] 프로시저 recompile 확인 및 사용
-- Reference : hanbitbook.co.kr
-- Key word : 프로시저 procedure recompile 리컴파일
**********************************************************************************************/
use tempdb;
go - drop table sptbl;
go - select *
into sptbl
from adventureworks.sales.customer
order by rowguid;
go - create nonclustered index idx_sptbl_id on sptbl (customerid);
go - --index seek
select * from sptbl where customerid < 10;
go - --table scan
select * from sptbl where customerid < 5000; - drop proc usp_id;
go - create proc usp_id
@id int
as
select * from sptbl where customerid < @id;
go - --index seek
exec usp_id 10;
go - --index seek한다~!!!!
exec usp_id 5000;
go - --table scan한다~!!!!
exec usp_id 5000 with recompile;
go - exec sp_recompile sptbl;
exec usp_id 10;
go - exec usp_id 10;
go - dbcc freeproccache;
exec usp_id 5000;
go - drop proc usp_id;
go - create proc usp_id
@id int
with recompile
as
select * from sptbl where customerid < @id;
go
exec usp_id 10;
go - exec usp_id 10000;
go
반응형