Statement Level Recompile
I've read that SQL Server 2005 supports statement-level recompile. Instead of having all queries in the stored procedure recompiled, SQL Server can now recompile individual statements.
When I create following procedure
SET NOCOUNT ON;
USE Northwind;
IF OBJECT_ID('dbo.useKeepPlan', 'P') IS NOT NULL
DROP PROC dbo.useKeepPlan;
GO
create procedure useKeepPlan as
create table #t (a int, b char(3))
-- Make greater than 6 changes to #t
insert #t values (1, 'abc')
insert #t values (2, 'abc')
insert #t values (3, 'abc')
insert #t values (4, 'abc')
insert #t values (5, 'abc')
insert #t values (6, 'abc')
insert #t values (7, 'abc')
-- Now reference #t
select count(*) from #t
go
and run it for first time I get
SP:Recompile
SQL:StmtRecomplie events
when select count(*) from #t statement is reached.
Should there only be SQL:StmtRecomplie event withouth entire procedure recompilation?
|