I have a Windows 2003 Server, what my plan is to compress sql server backup
file every night and ship in to different SQL Server Server, the question
is, is there any builtin zip/compress facility in windows which I can use it
for this purpose.
Thanks
If you are using the NTFS file system, you can just configure a directory to
be compressed in the advanced properties but when you read the file to send
it to the backup server, Windows will uncompress it so if you want the data
to be compressed on the wire, you will probably need to use some kind of zip
utility. Depending on how big the files are, compressing on the wire might
not make that big a difference so it might be enough to make the backup
directories compressed. Be sure you don't accidentally compress the
database files - this will break SQL Server.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Rogers" <naissani@.hotmail.com> wrote in message
news:eZves4UPGHA.1312@.TK2MSFTNGP09.phx.gbl...
>I have a Windows 2003 Server, what my plan is to compress sql server backup
>file every night and ship in to different SQL Server Server, the question
>is, is there any builtin zip/compress facility in windows which I can use
>it for this purpose.
> Thanks
>
|||Rogers wrote:
> I have a Windows 2003 Server, what my plan is to compress sql server
> backup file every night and ship in to different SQL Server Server,
> the question is, is there any builtin zip/compress facility in
> windows which I can use it for this purpose.
> Thanks
I would recommend you consider using a SQL Server backup and recovery
program that compresses and optionally encrypts backups in memory.
You'll save yourself a lot of backup (and recovery) time and won't have
to worry about post-backup compression. There are a number of companies
who have this type of software.
David Gugick - SQL Server MVP
Quest Software
|||Hi,
of course there are several tools in the market making a good job, but
sometimes you are really interested in a subset of their functionality
or your budget is really reduced. Four these cases, I would suggest
take a look here
http://spaces.msn.com/jcarlossaez/blog/cns!B3378F057444B65C!107.entry?_c11_blogpart_blogpart =blogview&_c=blogpart#permalink
Regards
Showing posts with label plan. Show all posts
Showing posts with label plan. Show all posts
Tuesday, March 20, 2012
Sunday, February 19, 2012
Compiled plans and syscacheobjects
Hi,
I'm wondering if someone knows what causes a compiled plan to get
dropped from the cache. We've got one fairly complicated procedure
that gets removed from cache every few minutes, and then compiled again
the next time its run. The compile takes 10-15 seconds of cpu. The
procedure is used 10-20 times per minute, so i dont think it's because
of lack of use. And we have other procedures called as often that dont
get dropped so frequently. As well, we have the identical procedure,
named differently (called from a different program) that shows the same
behavior, it gets dropped from the cache frequently.
Could it be related to the data the query is looking it?
Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
Thanks,
Trevortdunsford@.gmail.com wrote:
> Hi,
> I'm wondering if someone knows what causes a compiled plan to get
> dropped from the cache. We've got one fairly complicated procedure
> that gets removed from cache every few minutes, and then compiled again
> the next time its run. The compile takes 10-15 seconds of cpu. The
> procedure is used 10-20 times per minute, so i dont think it's because
> of lack of use. And we have other procedures called as often that dont
> get dropped so frequently. As well, we have the identical procedure,
> named differently (called from a different program) that shows the same
> behavior, it gets dropped from the cache frequently.
> Could it be related to the data the query is looking it?
> Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> Thanks,
> Trevor
>
Does this procedure create temp tables?
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||No, it uses table variables:
declare table @.tbl (...)
insert into @.tbl (...)
select ...
select * from @.tbl
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> > Hi,
> >
> > I'm wondering if someone knows what causes a compiled plan to get
> > dropped from the cache. We've got one fairly complicated procedure
> > that gets removed from cache every few minutes, and then compiled again
> > the next time its run. The compile takes 10-15 seconds of cpu. The
> > procedure is used 10-20 times per minute, so i dont think it's because
> > of lack of use. And we have other procedures called as often that dont
> > get dropped so frequently. As well, we have the identical procedure,
> > named differently (called from a different program) that shows the same
> > behavior, it gets dropped from the cache frequently.
> >
> > Could it be related to the data the query is looking it?
> >
> > Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> >
> > Thanks,
> >
> > Trevor
> >
> Does this procedure create temp tables?
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||tdunsford@.gmail.com wrote:
> No, it uses table variables:
> declare table @.tbl (...)
> insert into @.tbl (...)
> select ...
> select * from @.tbl
>
Have you reviewed this KB article?
http://support.microsoft.com/kb/243586
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||>From what i can understand, this talks about recompiles. I may be
mistaken, but I dont think thats what i'm seeing here. There is no
sp:recompile event. All the cpu/delay occurs before any of the
statements are executed (ie before SP:Starting).
I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
the compile plan in the cache as well, not just the execution plan?
Because recompiling the execution plan takes no time at all...its the
compile plan thats the killer.
Thanks,
Trevor
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> > No, it uses table variables:
> >
> > declare table @.tbl (...)
> >
> > insert into @.tbl (...)
> > select ...
> >
> > select * from @.tbl
> >
> Have you reviewed this KB article?
> http://support.microsoft.com/kb/243586
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||Yes you should look into these. The execution plan is based off the compiled
plan so you can't have an executionplan without the compiled plan.
--
Andrew J. Kelly SQL MVP
<tdunsford@.gmail.com> wrote in message
news:1161355332.974366.216790@.e3g2000cwe.googlegroups.com...
> >From what i can understand, this talks about recompiles. I may be
> mistaken, but I dont think thats what i'm seeing here. There is no
> sp:recompile event. All the cpu/delay occurs before any of the
> statements are executed (ie before SP:Starting).
> I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
> the compile plan in the cache as well, not just the execution plan?
> Because recompiling the execution plan takes no time at all...its the
> compile plan thats the killer.
> Thanks,
> Trevor
>
> Tracy McKibben wrote:
>> tdunsford@.gmail.com wrote:
>> > No, it uses table variables:
>> >
>> > declare table @.tbl (...)
>> >
>> > insert into @.tbl (...)
>> > select ...
>> >
>> > select * from @.tbl
>> >
>> Have you reviewed this KB article?
>> http://support.microsoft.com/kb/243586
>>
>> --
>> Tracy McKibben
>> MCDBA
>> http://www.realsqlguy.com
>
I'm wondering if someone knows what causes a compiled plan to get
dropped from the cache. We've got one fairly complicated procedure
that gets removed from cache every few minutes, and then compiled again
the next time its run. The compile takes 10-15 seconds of cpu. The
procedure is used 10-20 times per minute, so i dont think it's because
of lack of use. And we have other procedures called as often that dont
get dropped so frequently. As well, we have the identical procedure,
named differently (called from a different program) that shows the same
behavior, it gets dropped from the cache frequently.
Could it be related to the data the query is looking it?
Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
Thanks,
Trevortdunsford@.gmail.com wrote:
> Hi,
> I'm wondering if someone knows what causes a compiled plan to get
> dropped from the cache. We've got one fairly complicated procedure
> that gets removed from cache every few minutes, and then compiled again
> the next time its run. The compile takes 10-15 seconds of cpu. The
> procedure is used 10-20 times per minute, so i dont think it's because
> of lack of use. And we have other procedures called as often that dont
> get dropped so frequently. As well, we have the identical procedure,
> named differently (called from a different program) that shows the same
> behavior, it gets dropped from the cache frequently.
> Could it be related to the data the query is looking it?
> Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> Thanks,
> Trevor
>
Does this procedure create temp tables?
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||No, it uses table variables:
declare table @.tbl (...)
insert into @.tbl (...)
select ...
select * from @.tbl
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> > Hi,
> >
> > I'm wondering if someone knows what causes a compiled plan to get
> > dropped from the cache. We've got one fairly complicated procedure
> > that gets removed from cache every few minutes, and then compiled again
> > the next time its run. The compile takes 10-15 seconds of cpu. The
> > procedure is used 10-20 times per minute, so i dont think it's because
> > of lack of use. And we have other procedures called as often that dont
> > get dropped so frequently. As well, we have the identical procedure,
> > named differently (called from a different program) that shows the same
> > behavior, it gets dropped from the cache frequently.
> >
> > Could it be related to the data the query is looking it?
> >
> > Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> >
> > Thanks,
> >
> > Trevor
> >
> Does this procedure create temp tables?
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||tdunsford@.gmail.com wrote:
> No, it uses table variables:
> declare table @.tbl (...)
> insert into @.tbl (...)
> select ...
> select * from @.tbl
>
Have you reviewed this KB article?
http://support.microsoft.com/kb/243586
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||>From what i can understand, this talks about recompiles. I may be
mistaken, but I dont think thats what i'm seeing here. There is no
sp:recompile event. All the cpu/delay occurs before any of the
statements are executed (ie before SP:Starting).
I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
the compile plan in the cache as well, not just the execution plan?
Because recompiling the execution plan takes no time at all...its the
compile plan thats the killer.
Thanks,
Trevor
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> > No, it uses table variables:
> >
> > declare table @.tbl (...)
> >
> > insert into @.tbl (...)
> > select ...
> >
> > select * from @.tbl
> >
> Have you reviewed this KB article?
> http://support.microsoft.com/kb/243586
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||Yes you should look into these. The execution plan is based off the compiled
plan so you can't have an executionplan without the compiled plan.
--
Andrew J. Kelly SQL MVP
<tdunsford@.gmail.com> wrote in message
news:1161355332.974366.216790@.e3g2000cwe.googlegroups.com...
> >From what i can understand, this talks about recompiles. I may be
> mistaken, but I dont think thats what i'm seeing here. There is no
> sp:recompile event. All the cpu/delay occurs before any of the
> statements are executed (ie before SP:Starting).
> I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
> the compile plan in the cache as well, not just the execution plan?
> Because recompiling the execution plan takes no time at all...its the
> compile plan thats the killer.
> Thanks,
> Trevor
>
> Tracy McKibben wrote:
>> tdunsford@.gmail.com wrote:
>> > No, it uses table variables:
>> >
>> > declare table @.tbl (...)
>> >
>> > insert into @.tbl (...)
>> > select ...
>> >
>> > select * from @.tbl
>> >
>> Have you reviewed this KB article?
>> http://support.microsoft.com/kb/243586
>>
>> --
>> Tracy McKibben
>> MCDBA
>> http://www.realsqlguy.com
>
Compiled plans and syscacheobjects
Hi,
I'm wondering if someone knows what causes a compiled plan to get
dropped from the cache. We've got one fairly complicated procedure
that gets removed from cache every few minutes, and then compiled again
the next time its run. The compile takes 10-15 seconds of cpu. The
procedure is used 10-20 times per minute, so i dont think it's because
of lack of use. And we have other procedures called as often that dont
get dropped so frequently. As well, we have the identical procedure,
named differently (called from a different program) that shows the same
behavior, it gets dropped from the cache frequently.
Could it be related to the data the query is looking it?
Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
Thanks,
Trevor
tdunsford@.gmail.com wrote:
> Hi,
> I'm wondering if someone knows what causes a compiled plan to get
> dropped from the cache. We've got one fairly complicated procedure
> that gets removed from cache every few minutes, and then compiled again
> the next time its run. The compile takes 10-15 seconds of cpu. The
> procedure is used 10-20 times per minute, so i dont think it's because
> of lack of use. And we have other procedures called as often that dont
> get dropped so frequently. As well, we have the identical procedure,
> named differently (called from a different program) that shows the same
> behavior, it gets dropped from the cache frequently.
> Could it be related to the data the query is looking it?
> Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> Thanks,
> Trevor
>
Does this procedure create temp tables?
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||No, it uses table variables:
declare table @.tbl (...)
insert into @.tbl (...)
select ...
select * from @.tbl
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Does this procedure create temp tables?
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||tdunsford@.gmail.com wrote:
> No, it uses table variables:
> declare table @.tbl (...)
> insert into @.tbl (...)
> select ...
> select * from @.tbl
>
Have you reviewed this KB article?
http://support.microsoft.com/kb/243586
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||>From what i can understand, this talks about recompiles. I may be
mistaken, but I dont think thats what i'm seeing here. There is no
sp:recompile event. All the cpu/delay occurs before any of the
statements are executed (ie before SP:Starting).
I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
the compile plan in the cache as well, not just the execution plan?
Because recompiling the execution plan takes no time at all...its the
compile plan thats the killer.
Thanks,
Trevor
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Have you reviewed this KB article?
> http://support.microsoft.com/kb/243586
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||Yes you should look into these. The execution plan is based off the compiled
plan so you can't have an executionplan without the compiled plan.
Andrew J. Kelly SQL MVP
<tdunsford@.gmail.com> wrote in message
news:1161355332.974366.216790@.e3g2000cwe.googlegro ups.com...
> mistaken, but I dont think thats what i'm seeing here. There is no
> sp:recompile event. All the cpu/delay occurs before any of the
> statements are executed (ie before SP:Starting).
> I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
> the compile plan in the cache as well, not just the execution plan?
> Because recompiling the execution plan takes no time at all...its the
> compile plan thats the killer.
> Thanks,
> Trevor
>
> Tracy McKibben wrote:
>
I'm wondering if someone knows what causes a compiled plan to get
dropped from the cache. We've got one fairly complicated procedure
that gets removed from cache every few minutes, and then compiled again
the next time its run. The compile takes 10-15 seconds of cpu. The
procedure is used 10-20 times per minute, so i dont think it's because
of lack of use. And we have other procedures called as often that dont
get dropped so frequently. As well, we have the identical procedure,
named differently (called from a different program) that shows the same
behavior, it gets dropped from the cache frequently.
Could it be related to the data the query is looking it?
Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
Thanks,
Trevor
tdunsford@.gmail.com wrote:
> Hi,
> I'm wondering if someone knows what causes a compiled plan to get
> dropped from the cache. We've got one fairly complicated procedure
> that gets removed from cache every few minutes, and then compiled again
> the next time its run. The compile takes 10-15 seconds of cpu. The
> procedure is used 10-20 times per minute, so i dont think it's because
> of lack of use. And we have other procedures called as often that dont
> get dropped so frequently. As well, we have the identical procedure,
> named differently (called from a different program) that shows the same
> behavior, it gets dropped from the cache frequently.
> Could it be related to the data the query is looking it?
> Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> Thanks,
> Trevor
>
Does this procedure create temp tables?
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||No, it uses table variables:
declare table @.tbl (...)
insert into @.tbl (...)
select ...
select * from @.tbl
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Does this procedure create temp tables?
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||tdunsford@.gmail.com wrote:
> No, it uses table variables:
> declare table @.tbl (...)
> insert into @.tbl (...)
> select ...
> select * from @.tbl
>
Have you reviewed this KB article?
http://support.microsoft.com/kb/243586
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||>From what i can understand, this talks about recompiles. I may be
mistaken, but I dont think thats what i'm seeing here. There is no
sp:recompile event. All the cpu/delay occurs before any of the
statements are executed (ie before SP:Starting).
I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
the compile plan in the cache as well, not just the execution plan?
Because recompiling the execution plan takes no time at all...its the
compile plan thats the killer.
Thanks,
Trevor
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Have you reviewed this KB article?
> http://support.microsoft.com/kb/243586
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||Yes you should look into these. The execution plan is based off the compiled
plan so you can't have an executionplan without the compiled plan.
Andrew J. Kelly SQL MVP
<tdunsford@.gmail.com> wrote in message
news:1161355332.974366.216790@.e3g2000cwe.googlegro ups.com...
> mistaken, but I dont think thats what i'm seeing here. There is no
> sp:recompile event. All the cpu/delay occurs before any of the
> statements are executed (ie before SP:Starting).
> I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
> the compile plan in the cache as well, not just the execution plan?
> Because recompiling the execution plan takes no time at all...its the
> compile plan thats the killer.
> Thanks,
> Trevor
>
> Tracy McKibben wrote:
>
Labels:
cache,
causes,
compiled,
complicated,
database,
fairly,
getdropped,
knows,
microsoft,
mysql,
oracle,
plan,
plans,
procedurethat,
server,
sql,
syscacheobjects,
weve
Compiled plans and syscacheobjects
Hi,
I'm wondering if someone knows what causes a compiled plan to get
dropped from the cache. We've got one fairly complicated procedure
that gets removed from cache every few minutes, and then compiled again
the next time its run. The compile takes 10-15 seconds of cpu. The
procedure is used 10-20 times per minute, so i dont think it's because
of lack of use. And we have other procedures called as often that dont
get dropped so frequently. As well, we have the identical procedure,
named differently (called from a different program) that shows the same
behavior, it gets dropped from the cache frequently.
Could it be related to the data the query is looking it?
Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
Thanks,
Trevortdunsford@.gmail.com wrote:
> Hi,
> I'm wondering if someone knows what causes a compiled plan to get
> dropped from the cache. We've got one fairly complicated procedure
> that gets removed from cache every few minutes, and then compiled again
> the next time its run. The compile takes 10-15 seconds of cpu. The
> procedure is used 10-20 times per minute, so i dont think it's because
> of lack of use. And we have other procedures called as often that dont
> get dropped so frequently. As well, we have the identical procedure,
> named differently (called from a different program) that shows the same
> behavior, it gets dropped from the cache frequently.
> Could it be related to the data the query is looking it?
> Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> Thanks,
> Trevor
>
Does this procedure create temp tables?
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||No, it uses table variables:
declare table @.tbl (...)
insert into @.tbl (...)
select ...
select * from @.tbl
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Does this procedure create temp tables?
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||tdunsford@.gmail.com wrote:
> No, it uses table variables:
> declare table @.tbl (...)
> insert into @.tbl (...)
> select ...
> select * from @.tbl
>
Have you reviewed this KB article?
http://support.microsoft.com/kb/243586
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||>From what i can understand, this talks about recompiles. I may be
mistaken, but I dont think thats what i'm seeing here. There is no
sp:recompile event. All the cpu/delay occurs before any of the
statements are executed (ie before SP:Starting).
I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
the compile plan in the cache as well, not just the execution plan?
Because recompiling the execution plan takes no time at all...its the
compile plan thats the killer.
Thanks,
Trevor
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Have you reviewed this KB article?
> http://support.microsoft.com/kb/243586
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||Yes you should look into these. The execution plan is based off the compiled
plan so you can't have an executionplan without the compiled plan.
Andrew J. Kelly SQL MVP
<tdunsford@.gmail.com> wrote in message
news:1161355332.974366.216790@.e3g2000cwe.googlegroups.com...
> mistaken, but I dont think thats what i'm seeing here. There is no
> sp:recompile event. All the cpu/delay occurs before any of the
> statements are executed (ie before SP:Starting).
> I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
> the compile plan in the cache as well, not just the execution plan?
> Because recompiling the execution plan takes no time at all...its the
> compile plan thats the killer.
> Thanks,
> Trevor
>
> Tracy McKibben wrote:
>
I'm wondering if someone knows what causes a compiled plan to get
dropped from the cache. We've got one fairly complicated procedure
that gets removed from cache every few minutes, and then compiled again
the next time its run. The compile takes 10-15 seconds of cpu. The
procedure is used 10-20 times per minute, so i dont think it's because
of lack of use. And we have other procedures called as often that dont
get dropped so frequently. As well, we have the identical procedure,
named differently (called from a different program) that shows the same
behavior, it gets dropped from the cache frequently.
Could it be related to the data the query is looking it?
Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
Thanks,
Trevortdunsford@.gmail.com wrote:
> Hi,
> I'm wondering if someone knows what causes a compiled plan to get
> dropped from the cache. We've got one fairly complicated procedure
> that gets removed from cache every few minutes, and then compiled again
> the next time its run. The compile takes 10-15 seconds of cpu. The
> procedure is used 10-20 times per minute, so i dont think it's because
> of lack of use. And we have other procedures called as often that dont
> get dropped so frequently. As well, we have the identical procedure,
> named differently (called from a different program) that shows the same
> behavior, it gets dropped from the cache frequently.
> Could it be related to the data the query is looking it?
> Any ideas appreciated. Oh yeah, SQL Server 2000, SP3 i think.
> Thanks,
> Trevor
>
Does this procedure create temp tables?
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||No, it uses table variables:
declare table @.tbl (...)
insert into @.tbl (...)
select ...
select * from @.tbl
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Does this procedure create temp tables?
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||tdunsford@.gmail.com wrote:
> No, it uses table variables:
> declare table @.tbl (...)
> insert into @.tbl (...)
> select ...
> select * from @.tbl
>
Have you reviewed this KB article?
http://support.microsoft.com/kb/243586
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||>From what i can understand, this talks about recompiles. I may be
mistaken, but I dont think thats what i'm seeing here. There is no
sp:recompile event. All the cpu/delay occurs before any of the
statements are executed (ie before SP:Starting).
I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
the compile plan in the cache as well, not just the execution plan?
Because recompiling the execution plan takes no time at all...its the
compile plan thats the killer.
Thanks,
Trevor
Tracy McKibben wrote:
> tdunsford@.gmail.com wrote:
> Have you reviewed this KB article?
> http://support.microsoft.com/kb/243586
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||Yes you should look into these. The execution plan is based off the compiled
plan so you can't have an executionplan without the compiled plan.
Andrew J. Kelly SQL MVP
<tdunsford@.gmail.com> wrote in message
news:1161355332.974366.216790@.e3g2000cwe.googlegroups.com...
> mistaken, but I dont think thats what i'm seeing here. There is no
> sp:recompile event. All the cpu/delay occurs before any of the
> statements are executed (ie before SP:Starting).
> I see 2 options, KEEP PLAN and KEEPFIXED PLAN. Would this help keep
> the compile plan in the cache as well, not just the execution plan?
> Because recompiling the execution plan takes no time at all...its the
> compile plan thats the killer.
> Thanks,
> Trevor
>
> Tracy McKibben wrote:
>
Labels:
cache,
causes,
compiled,
complicated,
database,
fairly,
getdropped,
knows,
microsoft,
mysql,
oracle,
plan,
plans,
procedurethat,
server,
sql,
syscacheobjects
Friday, February 17, 2012
compilation and execution plan
Hi guys,
I'm confused on following situation, - I'm definitely missing something. I
have SP which plan is already in cache. The SP references table MyTable. I
setup trace on recompile and all cache related events and it runs during
test nonstop.
Here is what I did (before dash) and
what I saw in Profiler (after dash) on each action:
DBCC FREEPROCCACHE - sp:cacheremove
exec MySP - sp:cachemiss, sp:cacheinsert
drop procedure MySP - sp:cacheremove
CREATE PROCEDURE MySP - none
exec MySP - sp:cachemiss, sp:cacheinsert
exec sp_recompile MyTable - none
exec MySP - sp:ExecContextHit, sp:cacheremove,
sp:recompile,
sp:cachemiss, sp:cacheinsert
My question is Why I can't see sp:recompile events
when I execute SP after DBCC and then after DROP/CREATE statements?
My understanding is that if plan is removed from cache
it doesn't exist anymore and has to be compiled to enable SP to execute next
time (what we see when SP is executed after
exec sp_recompile MyTable)?
But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
inserted into cache but from where? On which step did it get compiled?
I'd be highly grateful for any information.
AlexAlex,
The difference is in the difference between the words "compile" and "recompile". If you drop and
create the proc, the proc plan doesn't exist and fir the first execution you get a compilation. Same
if you empty the proc cache.
However, if you sp_recompile a table that the proc is using, the plan is still in cache and for the
next execution SQL Server will need to REcompile that plan.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_remove_this_@.telus.net> wrote in message news:pSepd.2111$cE3.1783@.clgrps12...
> Hi guys,
> I'm confused on following situation, - I'm definitely missing something. I
> have SP which plan is already in cache. The SP references table MyTable. I
> setup trace on recompile and all cache related events and it runs during
> test nonstop.
> Here is what I did (before dash) and
> what I saw in Profiler (after dash) on each action:
> DBCC FREEPROCCACHE - sp:cacheremove
> exec MySP - sp:cachemiss, sp:cacheinsert
> drop procedure MySP - sp:cacheremove
> CREATE PROCEDURE MySP - none
> exec MySP - sp:cachemiss, sp:cacheinsert
> exec sp_recompile MyTable - none
> exec MySP - sp:ExecContextHit, sp:cacheremove,
> sp:recompile,
> sp:cachemiss, sp:cacheinsert
> My question is Why I can't see sp:recompile events
> when I execute SP after DBCC and then after DROP/CREATE statements?
> My understanding is that if plan is removed from cache
> it doesn't exist anymore and has to be compiled to enable SP to execute next
> time (what we see when SP is executed after
> exec sp_recompile MyTable)?
> But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
> inserted into cache but from where? On which step did it get compiled?
> I'd be highly grateful for any information.
> Alex
>|||Thank you Tibor,
So Profiler has event related to recompilation (sp:recompile) and doesn't
have event related to compilation, that's why we see only sp:cachemiss,
sp:cacheinsert and nothing in between?
Thank you,
Alex
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
"recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
news:pSepd.2111$cE3.1783@.clgrps12...
> > Hi guys,
> >
> > I'm confused on following situation, - I'm definitely missing something.
I
> > have SP which plan is already in cache. The SP references table MyTable.
I
> > setup trace on recompile and all cache related events and it runs during
> > test nonstop.
> >
> > Here is what I did (before dash) and
> > what I saw in Profiler (after dash) on each action:
> >
> > DBCC FREEPROCCACHE - sp:cacheremove
> > exec MySP - sp:cachemiss, sp:cacheinsert
> > drop procedure MySP - sp:cacheremove
> > CREATE PROCEDURE MySP - none
> > exec MySP - sp:cachemiss, sp:cacheinsert
> > exec sp_recompile MyTable - none
> > exec MySP - sp:ExecContextHit, sp:cacheremove,
> > sp:recompile,
> > sp:cachemiss, sp:cacheinsert
> >
> > My question is Why I can't see sp:recompile events
> > when I execute SP after DBCC and then after DROP/CREATE statements?
> > My understanding is that if plan is removed from cache
> > it doesn't exist anymore and has to be compiled to enable SP to execute
next
> > time (what we see when SP is executed after
> > exec sp_recompile MyTable)?
> > But instead we see sp:cacheinsert event right after sp:cachemiss event.
It's
> > inserted into cache but from where? On which step did it get compiled?
> >
> > I'd be highly grateful for any information.
> >
> > Alex
> >
> >
>|||Yep. :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_removethis_@.healthmetrx.com> wrote in message
news:10qc0uncauftpd9@.corp.supernews.com...
> Thank you Tibor,
> So Profiler has event related to recompilation (sp:recompile) and doesn't
> have event related to compilation, that's why we see only sp:cachemiss,
> sp:cacheinsert and nothing in between?
>
> Thank you,
> Alex
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> > Alex,
> >
> > The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> > create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> > if you empty the proc cache.
> >
> > However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> > next execution SQL Server will need to REcompile that plan.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
> > > Hi guys,
> > >
> > > I'm confused on following situation, - I'm definitely missing something.
> I
> > > have SP which plan is already in cache. The SP references table MyTable.
> I
> > > setup trace on recompile and all cache related events and it runs during
> > > test nonstop.
> > >
> > > Here is what I did (before dash) and
> > > what I saw in Profiler (after dash) on each action:
> > >
> > > DBCC FREEPROCCACHE - sp:cacheremove
> > > exec MySP - sp:cachemiss, sp:cacheinsert
> > > drop procedure MySP - sp:cacheremove
> > > CREATE PROCEDURE MySP - none
> > > exec MySP - sp:cachemiss, sp:cacheinsert
> > > exec sp_recompile MyTable - none
> > > exec MySP - sp:ExecContextHit, sp:cacheremove,
> > > sp:recompile,
> > > sp:cachemiss, sp:cacheinsert
> > >
> > > My question is Why I can't see sp:recompile events
> > > when I execute SP after DBCC and then after DROP/CREATE statements?
> > > My understanding is that if plan is removed from cache
> > > it doesn't exist anymore and has to be compiled to enable SP to execute
> next
> > > time (what we see when SP is executed after
> > > exec sp_recompile MyTable)?
> > > But instead we see sp:cacheinsert event right after sp:cachemiss event.
> It's
> > > inserted into cache but from where? On which step did it get compiled?
> > >
> > > I'd be highly grateful for any information.
> > >
> > > Alex
> > >
> > >
> >
> >
>|||On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
wrote:
>But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
>inserted into cache but from where? On which step did it get compiled?
>I'd be highly grateful for any information.
sp_recompile only marks the SP, it doesn't actually *do* the
compilation at that time, SQLServer "lazily" waits for the next call
for execution, and then compiles it.
J.|||JXStern wrote:
> On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> wrote:
> >But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
> >inserted into cache but from where? On which step did it get compiled?
> >
> >I'd be highly grateful for any information.
> sp_recompile only marks the SP, it doesn't actually *do* the
> compilation at that time, SQLServer "lazily" waits for the next call
> for execution, and then compiles it.
> J.
This "laziness" avoids unnecessary compilations.
However, there is also a technical reason that SP's are not recompiled
immediate after a schema change or sp_recompile. This is because the
compilation phase uses the stored procedure parameters so the most
representative statistics can be used, and thus will not 'guess'
parameter values. This basically means that SP's cannot be compiled
without calling them (with the appropriate parameters).
Gert-Jan|||Not quite.
The explanation of the terms is fine, but this is not how Profiler records
them.
If you actually look at what happens when you issue the sp_recompile, you'll
see a SP:CacheRemove event. Then the next time you call the proc, you'll see
SP:CacheInsert just as for the first time.
AFAIK, the SP:Recompile event is ONLY generated in the situation where a
stored procedure is recompiled while it is executing. This is caused by
activities in the sproc like DDL, updating statistics or changing a SET
option.
See KB 308737 for more details.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
>> Hi guys,
>> I'm confused on following situation, - I'm definitely missing something.
>> I
>> have SP which plan is already in cache. The SP references table MyTable.
>> I
>> setup trace on recompile and all cache related events and it runs during
>> test nonstop.
>> Here is what I did (before dash) and
>> what I saw in Profiler (after dash) on each action:
>> DBCC FREEPROCCACHE - sp:cacheremove
>> exec MySP - sp:cachemiss, sp:cacheinsert
>> drop procedure MySP - sp:cacheremove
>> CREATE PROCEDURE MySP - none
>> exec MySP - sp:cachemiss, sp:cacheinsert
>> exec sp_recompile MyTable - none
>> exec MySP - sp:ExecContextHit, sp:cacheremove,
>> sp:recompile,
>> sp:cachemiss, sp:cacheinsert
>> My question is Why I can't see sp:recompile events
>> when I execute SP after DBCC and then after DROP/CREATE statements?
>> My understanding is that if plan is removed from cache
>> it doesn't exist anymore and has to be compiled to enable SP to execute
>> next
>> time (what we see when SP is executed after
>> exec sp_recompile MyTable)?
>> But instead we see sp:cacheinsert event right after sp:cachemiss event.
>> It's
>> inserted into cache but from where? On which step did it get compiled?
>> I'd be highly grateful for any information.
>> Alex
>>
>|||Thank you guys for all that information
Alex
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:41A77B97.DA602FD7@.toomuchspamalready.nl...
> JXStern wrote:
> >
> > On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> > wrote:
> > >But instead we see sp:cacheinsert event right after sp:cachemiss event.
It's
> > >inserted into cache but from where? On which step did it get compiled?
> > >
> > >I'd be highly grateful for any information.
> >
> > sp_recompile only marks the SP, it doesn't actually *do* the
> > compilation at that time, SQLServer "lazily" waits for the next call
> > for execution, and then compiles it.
> >
> > J.
> This "laziness" avoids unnecessary compilations.
> However, there is also a technical reason that SP's are not recompiled
> immediate after a schema change or sp_recompile. This is because the
> compilation phase uses the stored procedure parameters so the most
> representative statistics can be used, and thus will not 'guess'
> parameter values. This basically means that SP's cannot be compiled
> without calling them (with the appropriate parameters).
> Gert-Jan
I'm confused on following situation, - I'm definitely missing something. I
have SP which plan is already in cache. The SP references table MyTable. I
setup trace on recompile and all cache related events and it runs during
test nonstop.
Here is what I did (before dash) and
what I saw in Profiler (after dash) on each action:
DBCC FREEPROCCACHE - sp:cacheremove
exec MySP - sp:cachemiss, sp:cacheinsert
drop procedure MySP - sp:cacheremove
CREATE PROCEDURE MySP - none
exec MySP - sp:cachemiss, sp:cacheinsert
exec sp_recompile MyTable - none
exec MySP - sp:ExecContextHit, sp:cacheremove,
sp:recompile,
sp:cachemiss, sp:cacheinsert
My question is Why I can't see sp:recompile events
when I execute SP after DBCC and then after DROP/CREATE statements?
My understanding is that if plan is removed from cache
it doesn't exist anymore and has to be compiled to enable SP to execute next
time (what we see when SP is executed after
exec sp_recompile MyTable)?
But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
inserted into cache but from where? On which step did it get compiled?
I'd be highly grateful for any information.
AlexAlex,
The difference is in the difference between the words "compile" and "recompile". If you drop and
create the proc, the proc plan doesn't exist and fir the first execution you get a compilation. Same
if you empty the proc cache.
However, if you sp_recompile a table that the proc is using, the plan is still in cache and for the
next execution SQL Server will need to REcompile that plan.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_remove_this_@.telus.net> wrote in message news:pSepd.2111$cE3.1783@.clgrps12...
> Hi guys,
> I'm confused on following situation, - I'm definitely missing something. I
> have SP which plan is already in cache. The SP references table MyTable. I
> setup trace on recompile and all cache related events and it runs during
> test nonstop.
> Here is what I did (before dash) and
> what I saw in Profiler (after dash) on each action:
> DBCC FREEPROCCACHE - sp:cacheremove
> exec MySP - sp:cachemiss, sp:cacheinsert
> drop procedure MySP - sp:cacheremove
> CREATE PROCEDURE MySP - none
> exec MySP - sp:cachemiss, sp:cacheinsert
> exec sp_recompile MyTable - none
> exec MySP - sp:ExecContextHit, sp:cacheremove,
> sp:recompile,
> sp:cachemiss, sp:cacheinsert
> My question is Why I can't see sp:recompile events
> when I execute SP after DBCC and then after DROP/CREATE statements?
> My understanding is that if plan is removed from cache
> it doesn't exist anymore and has to be compiled to enable SP to execute next
> time (what we see when SP is executed after
> exec sp_recompile MyTable)?
> But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
> inserted into cache but from where? On which step did it get compiled?
> I'd be highly grateful for any information.
> Alex
>|||Thank you Tibor,
So Profiler has event related to recompilation (sp:recompile) and doesn't
have event related to compilation, that's why we see only sp:cachemiss,
sp:cacheinsert and nothing in between?
Thank you,
Alex
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
"recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
news:pSepd.2111$cE3.1783@.clgrps12...
> > Hi guys,
> >
> > I'm confused on following situation, - I'm definitely missing something.
I
> > have SP which plan is already in cache. The SP references table MyTable.
I
> > setup trace on recompile and all cache related events and it runs during
> > test nonstop.
> >
> > Here is what I did (before dash) and
> > what I saw in Profiler (after dash) on each action:
> >
> > DBCC FREEPROCCACHE - sp:cacheremove
> > exec MySP - sp:cachemiss, sp:cacheinsert
> > drop procedure MySP - sp:cacheremove
> > CREATE PROCEDURE MySP - none
> > exec MySP - sp:cachemiss, sp:cacheinsert
> > exec sp_recompile MyTable - none
> > exec MySP - sp:ExecContextHit, sp:cacheremove,
> > sp:recompile,
> > sp:cachemiss, sp:cacheinsert
> >
> > My question is Why I can't see sp:recompile events
> > when I execute SP after DBCC and then after DROP/CREATE statements?
> > My understanding is that if plan is removed from cache
> > it doesn't exist anymore and has to be compiled to enable SP to execute
next
> > time (what we see when SP is executed after
> > exec sp_recompile MyTable)?
> > But instead we see sp:cacheinsert event right after sp:cachemiss event.
It's
> > inserted into cache but from where? On which step did it get compiled?
> >
> > I'd be highly grateful for any information.
> >
> > Alex
> >
> >
>|||Yep. :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_removethis_@.healthmetrx.com> wrote in message
news:10qc0uncauftpd9@.corp.supernews.com...
> Thank you Tibor,
> So Profiler has event related to recompilation (sp:recompile) and doesn't
> have event related to compilation, that's why we see only sp:cachemiss,
> sp:cacheinsert and nothing in between?
>
> Thank you,
> Alex
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> > Alex,
> >
> > The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> > create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> > if you empty the proc cache.
> >
> > However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> > next execution SQL Server will need to REcompile that plan.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
> > > Hi guys,
> > >
> > > I'm confused on following situation, - I'm definitely missing something.
> I
> > > have SP which plan is already in cache. The SP references table MyTable.
> I
> > > setup trace on recompile and all cache related events and it runs during
> > > test nonstop.
> > >
> > > Here is what I did (before dash) and
> > > what I saw in Profiler (after dash) on each action:
> > >
> > > DBCC FREEPROCCACHE - sp:cacheremove
> > > exec MySP - sp:cachemiss, sp:cacheinsert
> > > drop procedure MySP - sp:cacheremove
> > > CREATE PROCEDURE MySP - none
> > > exec MySP - sp:cachemiss, sp:cacheinsert
> > > exec sp_recompile MyTable - none
> > > exec MySP - sp:ExecContextHit, sp:cacheremove,
> > > sp:recompile,
> > > sp:cachemiss, sp:cacheinsert
> > >
> > > My question is Why I can't see sp:recompile events
> > > when I execute SP after DBCC and then after DROP/CREATE statements?
> > > My understanding is that if plan is removed from cache
> > > it doesn't exist anymore and has to be compiled to enable SP to execute
> next
> > > time (what we see when SP is executed after
> > > exec sp_recompile MyTable)?
> > > But instead we see sp:cacheinsert event right after sp:cachemiss event.
> It's
> > > inserted into cache but from where? On which step did it get compiled?
> > >
> > > I'd be highly grateful for any information.
> > >
> > > Alex
> > >
> > >
> >
> >
>|||On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
wrote:
>But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
>inserted into cache but from where? On which step did it get compiled?
>I'd be highly grateful for any information.
sp_recompile only marks the SP, it doesn't actually *do* the
compilation at that time, SQLServer "lazily" waits for the next call
for execution, and then compiles it.
J.|||JXStern wrote:
> On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> wrote:
> >But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
> >inserted into cache but from where? On which step did it get compiled?
> >
> >I'd be highly grateful for any information.
> sp_recompile only marks the SP, it doesn't actually *do* the
> compilation at that time, SQLServer "lazily" waits for the next call
> for execution, and then compiles it.
> J.
This "laziness" avoids unnecessary compilations.
However, there is also a technical reason that SP's are not recompiled
immediate after a schema change or sp_recompile. This is because the
compilation phase uses the stored procedure parameters so the most
representative statistics can be used, and thus will not 'guess'
parameter values. This basically means that SP's cannot be compiled
without calling them (with the appropriate parameters).
Gert-Jan|||Not quite.
The explanation of the terms is fine, but this is not how Profiler records
them.
If you actually look at what happens when you issue the sp_recompile, you'll
see a SP:CacheRemove event. Then the next time you call the proc, you'll see
SP:CacheInsert just as for the first time.
AFAIK, the SP:Recompile event is ONLY generated in the situation where a
stored procedure is recompiled while it is executing. This is caused by
activities in the sproc like DDL, updating statistics or changing a SET
option.
See KB 308737 for more details.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
>> Hi guys,
>> I'm confused on following situation, - I'm definitely missing something.
>> I
>> have SP which plan is already in cache. The SP references table MyTable.
>> I
>> setup trace on recompile and all cache related events and it runs during
>> test nonstop.
>> Here is what I did (before dash) and
>> what I saw in Profiler (after dash) on each action:
>> DBCC FREEPROCCACHE - sp:cacheremove
>> exec MySP - sp:cachemiss, sp:cacheinsert
>> drop procedure MySP - sp:cacheremove
>> CREATE PROCEDURE MySP - none
>> exec MySP - sp:cachemiss, sp:cacheinsert
>> exec sp_recompile MyTable - none
>> exec MySP - sp:ExecContextHit, sp:cacheremove,
>> sp:recompile,
>> sp:cachemiss, sp:cacheinsert
>> My question is Why I can't see sp:recompile events
>> when I execute SP after DBCC and then after DROP/CREATE statements?
>> My understanding is that if plan is removed from cache
>> it doesn't exist anymore and has to be compiled to enable SP to execute
>> next
>> time (what we see when SP is executed after
>> exec sp_recompile MyTable)?
>> But instead we see sp:cacheinsert event right after sp:cachemiss event.
>> It's
>> inserted into cache but from where? On which step did it get compiled?
>> I'd be highly grateful for any information.
>> Alex
>>
>|||Thank you guys for all that information
Alex
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:41A77B97.DA602FD7@.toomuchspamalready.nl...
> JXStern wrote:
> >
> > On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> > wrote:
> > >But instead we see sp:cacheinsert event right after sp:cachemiss event.
It's
> > >inserted into cache but from where? On which step did it get compiled?
> > >
> > >I'd be highly grateful for any information.
> >
> > sp_recompile only marks the SP, it doesn't actually *do* the
> > compilation at that time, SQLServer "lazily" waits for the next call
> > for execution, and then compiles it.
> >
> > J.
> This "laziness" avoids unnecessary compilations.
> However, there is also a technical reason that SP's are not recompiled
> immediate after a schema change or sp_recompile. This is because the
> compilation phase uses the stored procedure parameters so the most
> representative statistics can be used, and thus will not 'guess'
> parameter values. This basically means that SP's cannot be compiled
> without calling them (with the appropriate parameters).
> Gert-Jan
compilation and execution plan
Hi guys,
I'm confused on following situation, - I'm definitely missing something. I
have SP which plan is already in cache. The SP references table MyTable. I
setup trace on recompile and all cache related events and it runs during
test nonstop.
Here is what I did (before dash) and
what I saw in Profiler (after dash) on each action:
DBCC FREEPROCCACHE - sp:cacheremove
exec MySP - sp:cachemiss, sp:cacheinsert
drop procedure MySP - sp:cacheremove
CREATE PROCEDURE MySP - none
exec MySP - sp:cachemiss, sp:cacheinsert
exec sp_recompile MyTable - none
exec MySP - sp:ExecContextHit, sp:cacheremove,
sp:recompile,
sp:cachemiss, sp:cacheinsert
My question is Why I can't see sp:recompile events
when I execute SP after DBCC and then after DROP/CREATE statements?
My understanding is that if plan is removed from cache
it doesn't exist anymore and has to be compiled to enable SP to execute next
time (what we see when SP is executed after
exec sp_recompile MyTable)?
But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
inserted into cache but from where? On which step did it get compiled?
I'd be highly grateful for any information.
Alex
Alex,
The difference is in the difference between the words "compile" and "recompile". If you drop and
create the proc, the proc plan doesn't exist and fir the first execution you get a compilation. Same
if you empty the proc cache.
However, if you sp_recompile a table that the proc is using, the plan is still in cache and for the
next execution SQL Server will need to REcompile that plan.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_remove_this_@.telus.net> wrote in message news:pSepd.2111$cE3.1783@.clgrps12...
> Hi guys,
> I'm confused on following situation, - I'm definitely missing something. I
> have SP which plan is already in cache. The SP references table MyTable. I
> setup trace on recompile and all cache related events and it runs during
> test nonstop.
> Here is what I did (before dash) and
> what I saw in Profiler (after dash) on each action:
> DBCC FREEPROCCACHE - sp:cacheremove
> exec MySP - sp:cachemiss, sp:cacheinsert
> drop procedure MySP - sp:cacheremove
> CREATE PROCEDURE MySP - none
> exec MySP - sp:cachemiss, sp:cacheinsert
> exec sp_recompile MyTable - none
> exec MySP - sp:ExecContextHit, sp:cacheremove,
> sp:recompile,
> sp:cachemiss, sp:cacheinsert
> My question is Why I can't see sp:recompile events
> when I execute SP after DBCC and then after DROP/CREATE statements?
> My understanding is that if plan is removed from cache
> it doesn't exist anymore and has to be compiled to enable SP to execute next
> time (what we see when SP is executed after
> exec sp_recompile MyTable)?
> But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
> inserted into cache but from where? On which step did it get compiled?
> I'd be highly grateful for any information.
> Alex
>
|||Thank you Tibor,
So Profiler has event related to recompilation (sp:recompile) and doesn't
have event related to compilation, that's why we see only sp:cachemiss,
sp:cacheinsert and nothing in between?
Thank you,
Alex
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
"recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
news:pSepd.2111$cE3.1783@.clgrps12...[vbcol=seagreen]
I[vbcol=seagreen]
I[vbcol=seagreen]
next[vbcol=seagreen]
It's
>
|||Yep. :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_removethis_@.healthmetrx.com> wrote in message
news:10qc0uncauftpd9@.corp.supernews.com...
> Thank you Tibor,
> So Profiler has event related to recompilation (sp:recompile) and doesn't
> have event related to compilation, that's why we see only sp:cachemiss,
> sp:cacheinsert and nothing in between?
>
> Thank you,
> Alex
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> "recompile". If you drop and
> you get a compilation. Same
> still in cache and for the
> news:pSepd.2111$cE3.1783@.clgrps12...
> I
> I
> next
> It's
>
|||On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
wrote:
>But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
>inserted into cache but from where? On which step did it get compiled?
>I'd be highly grateful for any information.
sp_recompile only marks the SP, it doesn't actually *do* the
compilation at that time, SQLServer "lazily" waits for the next call
for execution, and then compiles it.
J.
|||JXStern wrote:
> On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> wrote:
> sp_recompile only marks the SP, it doesn't actually *do* the
> compilation at that time, SQLServer "lazily" waits for the next call
> for execution, and then compiles it.
> J.
This "laziness" avoids unnecessary compilations.
However, there is also a technical reason that SP's are not recompiled
immediate after a schema change or sp_recompile. This is because the
compilation phase uses the stored procedure parameters so the most
representative statistics can be used, and thus will not 'guess'
parameter values. This basically means that SP's cannot be compiled
without calling them (with the appropriate parameters).
Gert-Jan
|||Not quite.
The explanation of the terms is fine, but this is not how Profiler records
them.
If you actually look at what happens when you issue the sp_recompile, you'll
see a SP:CacheRemove event. Then the next time you call the proc, you'll see
SP:CacheInsert just as for the first time.
AFAIK, the SP:Recompile event is ONLY generated in the situation where a
stored procedure is recompiled while it is executing. This is caused by
activities in the sproc like DDL, updating statistics or changing a SET
option.
See KB 308737 for more details.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
>
|||Thank you guys for all that information
Alex
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:41A77B97.DA602FD7@.toomuchspamalready.nl...[vbcol=seagreen]
> JXStern wrote:
It's
> This "laziness" avoids unnecessary compilations.
> However, there is also a technical reason that SP's are not recompiled
> immediate after a schema change or sp_recompile. This is because the
> compilation phase uses the stored procedure parameters so the most
> representative statistics can be used, and thus will not 'guess'
> parameter values. This basically means that SP's cannot be compiled
> without calling them (with the appropriate parameters).
> Gert-Jan
I'm confused on following situation, - I'm definitely missing something. I
have SP which plan is already in cache. The SP references table MyTable. I
setup trace on recompile and all cache related events and it runs during
test nonstop.
Here is what I did (before dash) and
what I saw in Profiler (after dash) on each action:
DBCC FREEPROCCACHE - sp:cacheremove
exec MySP - sp:cachemiss, sp:cacheinsert
drop procedure MySP - sp:cacheremove
CREATE PROCEDURE MySP - none
exec MySP - sp:cachemiss, sp:cacheinsert
exec sp_recompile MyTable - none
exec MySP - sp:ExecContextHit, sp:cacheremove,
sp:recompile,
sp:cachemiss, sp:cacheinsert
My question is Why I can't see sp:recompile events
when I execute SP after DBCC and then after DROP/CREATE statements?
My understanding is that if plan is removed from cache
it doesn't exist anymore and has to be compiled to enable SP to execute next
time (what we see when SP is executed after
exec sp_recompile MyTable)?
But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
inserted into cache but from where? On which step did it get compiled?
I'd be highly grateful for any information.
Alex
Alex,
The difference is in the difference between the words "compile" and "recompile". If you drop and
create the proc, the proc plan doesn't exist and fir the first execution you get a compilation. Same
if you empty the proc cache.
However, if you sp_recompile a table that the proc is using, the plan is still in cache and for the
next execution SQL Server will need to REcompile that plan.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_remove_this_@.telus.net> wrote in message news:pSepd.2111$cE3.1783@.clgrps12...
> Hi guys,
> I'm confused on following situation, - I'm definitely missing something. I
> have SP which plan is already in cache. The SP references table MyTable. I
> setup trace on recompile and all cache related events and it runs during
> test nonstop.
> Here is what I did (before dash) and
> what I saw in Profiler (after dash) on each action:
> DBCC FREEPROCCACHE - sp:cacheremove
> exec MySP - sp:cachemiss, sp:cacheinsert
> drop procedure MySP - sp:cacheremove
> CREATE PROCEDURE MySP - none
> exec MySP - sp:cachemiss, sp:cacheinsert
> exec sp_recompile MyTable - none
> exec MySP - sp:ExecContextHit, sp:cacheremove,
> sp:recompile,
> sp:cachemiss, sp:cacheinsert
> My question is Why I can't see sp:recompile events
> when I execute SP after DBCC and then after DROP/CREATE statements?
> My understanding is that if plan is removed from cache
> it doesn't exist anymore and has to be compiled to enable SP to execute next
> time (what we see when SP is executed after
> exec sp_recompile MyTable)?
> But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
> inserted into cache but from where? On which step did it get compiled?
> I'd be highly grateful for any information.
> Alex
>
|||Thank you Tibor,
So Profiler has event related to recompilation (sp:recompile) and doesn't
have event related to compilation, that's why we see only sp:cachemiss,
sp:cacheinsert and nothing in between?
Thank you,
Alex
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
"recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
news:pSepd.2111$cE3.1783@.clgrps12...[vbcol=seagreen]
I[vbcol=seagreen]
I[vbcol=seagreen]
next[vbcol=seagreen]
It's
>
|||Yep. :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_removethis_@.healthmetrx.com> wrote in message
news:10qc0uncauftpd9@.corp.supernews.com...
> Thank you Tibor,
> So Profiler has event related to recompilation (sp:recompile) and doesn't
> have event related to compilation, that's why we see only sp:cachemiss,
> sp:cacheinsert and nothing in between?
>
> Thank you,
> Alex
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> "recompile". If you drop and
> you get a compilation. Same
> still in cache and for the
> news:pSepd.2111$cE3.1783@.clgrps12...
> I
> I
> next
> It's
>
|||On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
wrote:
>But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
>inserted into cache but from where? On which step did it get compiled?
>I'd be highly grateful for any information.
sp_recompile only marks the SP, it doesn't actually *do* the
compilation at that time, SQLServer "lazily" waits for the next call
for execution, and then compiles it.
J.
|||JXStern wrote:
> On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> wrote:
> sp_recompile only marks the SP, it doesn't actually *do* the
> compilation at that time, SQLServer "lazily" waits for the next call
> for execution, and then compiles it.
> J.
This "laziness" avoids unnecessary compilations.
However, there is also a technical reason that SP's are not recompiled
immediate after a schema change or sp_recompile. This is because the
compilation phase uses the stored procedure parameters so the most
representative statistics can be used, and thus will not 'guess'
parameter values. This basically means that SP's cannot be compiled
without calling them (with the appropriate parameters).
Gert-Jan
|||Not quite.
The explanation of the terms is fine, but this is not how Profiler records
them.
If you actually look at what happens when you issue the sp_recompile, you'll
see a SP:CacheRemove event. Then the next time you call the proc, you'll see
SP:CacheInsert just as for the first time.
AFAIK, the SP:Recompile event is ONLY generated in the situation where a
stored procedure is recompiled while it is executing. This is caused by
activities in the sproc like DDL, updating statistics or changing a SET
option.
See KB 308737 for more details.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
>
|||Thank you guys for all that information
Alex
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:41A77B97.DA602FD7@.toomuchspamalready.nl...[vbcol=seagreen]
> JXStern wrote:
It's
> This "laziness" avoids unnecessary compilations.
> However, there is also a technical reason that SP's are not recompiled
> immediate after a schema change or sp_recompile. This is because the
> compilation phase uses the stored procedure parameters so the most
> representative statistics can be used, and thus will not 'guess'
> parameter values. This basically means that SP's cannot be compiled
> without calling them (with the appropriate parameters).
> Gert-Jan
compilation and execution plan
Hi guys,
I'm confused on following situation, - I'm definitely missing something. I
have SP which plan is already in cache. The SP references table MyTable. I
setup trace on recompile and all cache related events and it runs during
test nonstop.
Here is what I did (before dash) and
what I saw in Profiler (after dash) on each action:
DBCC FREEPROCCACHE - sp:cacheremove
exec MySP - sp:cachemiss, sp:cacheinsert
drop procedure MySP - sp:cacheremove
CREATE PROCEDURE MySP - none
exec MySP - sp:cachemiss, sp:cacheinsert
exec sp_recompile MyTable - none
exec MySP - sp:ExecContextHit, sp:cacheremove,
sp:recompile,
sp:cachemiss, sp:cacheinsert
My question is Why I can't see sp:recompile events
when I execute SP after DBCC and then after DROP/CREATE statements?
My understanding is that if plan is removed from cache
it doesn't exist anymore and has to be compiled to enable SP to execute next
time (what we see when SP is executed after
exec sp_recompile MyTable)?
But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
inserted into cache but from where? On which step did it get compiled?
I'd be highly grateful for any information.
AlexAlex,
The difference is in the difference between the words "compile" and "recompi
le". If you drop and
create the proc, the proc plan doesn't exist and fir the first execution you
get a compilation. Same
if you empty the proc cache.
However, if you sp_recompile a table that the proc is using, the plan is sti
ll in cache and for the
next execution SQL Server will need to REcompile that plan.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_remove_this_@.telus.net> wrote in message news:pSepd.2111$cE3.1783@.clgrps12...[v
bcol=seagreen]
> Hi guys,
> I'm confused on following situation, - I'm definitely missing something. I
> have SP which plan is already in cache. The SP references table MyTable. I
> setup trace on recompile and all cache related events and it runs during
> test nonstop.
> Here is what I did (before dash) and
> what I saw in Profiler (after dash) on each action:
> DBCC FREEPROCCACHE - sp:cacheremove
> exec MySP - sp:cachemiss, sp:cacheinsert
> drop procedure MySP - sp:cacheremove
> CREATE PROCEDURE MySP - none
> exec MySP - sp:cachemiss, sp:cacheinsert
> exec sp_recompile MyTable - none
> exec MySP - sp:ExecContextHit, sp:cacheremove,
> sp:recompile,
> sp:cachemiss, sp:cacheinsert
> My question is Why I can't see sp:recompile events
> when I execute SP after DBCC and then after DROP/CREATE statements?
> My understanding is that if plan is removed from cache
> it doesn't exist anymore and has to be compiled to enable SP to execute ne
xt
> time (what we see when SP is executed after
> exec sp_recompile MyTable)?
> But instead we see sp:cacheinsert event right after sp:cachemiss event. It
's
> inserted into cache but from where? On which step did it get compiled?
> I'd be highly grateful for any information.
> Alex
>[/vbcol]|||Thank you Tibor,
So Profiler has event related to recompilation (sp:recompile) and doesn't
have event related to compilation, that's why we see only sp:cachemiss,
sp:cacheinsert and nothing in between?
Thank you,
Alex
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
"recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
news:pSepd.2111$cE3.1783@.clgrps12...
I[vbcol=seagreen]
I[vbcol=seagreen]
next[vbcol=seagreen]
It's[vbcol=seagreen]
>|||Yep. :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_removethis_@.healthmetrx.com> wrote in message
news:10qc0uncauftpd9@.corp.supernews.com...
> Thank you Tibor,
> So Profiler has event related to recompilation (sp:recompile) and doesn't
> have event related to compilation, that's why we see only sp:cachemiss,
> sp:cacheinsert and nothing in between?
>
> Thank you,
> Alex
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n
> message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> "recompile". If you drop and
> you get a compilation. Same
> still in cache and for the
> news:pSepd.2111$cE3.1783@.clgrps12...
> I
> I
> next
> It's
>|||On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
wrote:
>But instead we see sp:cacheinsert event right after sp:cachemiss event. It'
s
>inserted into cache but from where? On which step did it get compiled?
>I'd be highly grateful for any information.
sp_recompile only marks the SP, it doesn't actually *do* the
compilation at that time, SQLServer "lazily" waits for the next call
for execution, and then compiles it.
J.|||JXStern wrote:
> On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> wrote:
> sp_recompile only marks the SP, it doesn't actually *do* the
> compilation at that time, SQLServer "lazily" waits for the next call
> for execution, and then compiles it.
> J.
This "laziness" avoids unnecessary compilations.
However, there is also a technical reason that SP's are not recompiled
immediate after a schema change or sp_recompile. This is because the
compilation phase uses the stored procedure parameters so the most
representative statistics can be used, and thus will not 'guess'
parameter values. This basically means that SP's cannot be compiled
without calling them (with the appropriate parameters).
Gert-Jan|||Not quite.
The explanation of the terms is fine, but this is not how Profiler records
them.
If you actually look at what happens when you issue the sp_recompile, you'll
see a SP:CacheRemove event. Then the next time you call the proc, you'll see
SP:CacheInsert just as for the first time.
AFAIK, the SP:Recompile event is ONLY generated in the situation where a
stored procedure is recompiled while it is executing. This is caused by
activities in the sproc like DDL, updating statistics or changing a SET
option.
See KB 308737 for more details.
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
>|||Thank you guys for all that information
Alex
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:41A77B97.DA602FD7@.toomuchspamalready.nl...
> JXStern wrote:
It's[vbcol=seagreen]
> This "laziness" avoids unnecessary compilations.
> However, there is also a technical reason that SP's are not recompiled
> immediate after a schema change or sp_recompile. This is because the
> compilation phase uses the stored procedure parameters so the most
> representative statistics can be used, and thus will not 'guess'
> parameter values. This basically means that SP's cannot be compiled
> without calling them (with the appropriate parameters).
> Gert-Jan
I'm confused on following situation, - I'm definitely missing something. I
have SP which plan is already in cache. The SP references table MyTable. I
setup trace on recompile and all cache related events and it runs during
test nonstop.
Here is what I did (before dash) and
what I saw in Profiler (after dash) on each action:
DBCC FREEPROCCACHE - sp:cacheremove
exec MySP - sp:cachemiss, sp:cacheinsert
drop procedure MySP - sp:cacheremove
CREATE PROCEDURE MySP - none
exec MySP - sp:cachemiss, sp:cacheinsert
exec sp_recompile MyTable - none
exec MySP - sp:ExecContextHit, sp:cacheremove,
sp:recompile,
sp:cachemiss, sp:cacheinsert
My question is Why I can't see sp:recompile events
when I execute SP after DBCC and then after DROP/CREATE statements?
My understanding is that if plan is removed from cache
it doesn't exist anymore and has to be compiled to enable SP to execute next
time (what we see when SP is executed after
exec sp_recompile MyTable)?
But instead we see sp:cacheinsert event right after sp:cachemiss event. It's
inserted into cache but from where? On which step did it get compiled?
I'd be highly grateful for any information.
AlexAlex,
The difference is in the difference between the words "compile" and "recompi
le". If you drop and
create the proc, the proc plan doesn't exist and fir the first execution you
get a compilation. Same
if you empty the proc cache.
However, if you sp_recompile a table that the proc is using, the plan is sti
ll in cache and for the
next execution SQL Server will need to REcompile that plan.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_remove_this_@.telus.net> wrote in message news:pSepd.2111$cE3.1783@.clgrps12...[v
bcol=seagreen]
> Hi guys,
> I'm confused on following situation, - I'm definitely missing something. I
> have SP which plan is already in cache. The SP references table MyTable. I
> setup trace on recompile and all cache related events and it runs during
> test nonstop.
> Here is what I did (before dash) and
> what I saw in Profiler (after dash) on each action:
> DBCC FREEPROCCACHE - sp:cacheremove
> exec MySP - sp:cachemiss, sp:cacheinsert
> drop procedure MySP - sp:cacheremove
> CREATE PROCEDURE MySP - none
> exec MySP - sp:cachemiss, sp:cacheinsert
> exec sp_recompile MyTable - none
> exec MySP - sp:ExecContextHit, sp:cacheremove,
> sp:recompile,
> sp:cachemiss, sp:cacheinsert
> My question is Why I can't see sp:recompile events
> when I execute SP after DBCC and then after DROP/CREATE statements?
> My understanding is that if plan is removed from cache
> it doesn't exist anymore and has to be compiled to enable SP to execute ne
xt
> time (what we see when SP is executed after
> exec sp_recompile MyTable)?
> But instead we see sp:cacheinsert event right after sp:cachemiss event. It
's
> inserted into cache but from where? On which step did it get compiled?
> I'd be highly grateful for any information.
> Alex
>[/vbcol]|||Thank you Tibor,
So Profiler has event related to recompilation (sp:recompile) and doesn't
have event related to compilation, that's why we see only sp:cachemiss,
sp:cacheinsert and nothing in between?
Thank you,
Alex
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
"recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
news:pSepd.2111$cE3.1783@.clgrps12...
I[vbcol=seagreen]
I[vbcol=seagreen]
next[vbcol=seagreen]
It's[vbcol=seagreen]
>|||Yep. :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Alex" <alex_removethis_@.healthmetrx.com> wrote in message
news:10qc0uncauftpd9@.corp.supernews.com...
> Thank you Tibor,
> So Profiler has event related to recompilation (sp:recompile) and doesn't
> have event related to compilation, that's why we see only sp:cachemiss,
> sp:cacheinsert and nothing in between?
>
> Thank you,
> Alex
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n
> message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> "recompile". If you drop and
> you get a compilation. Same
> still in cache and for the
> news:pSepd.2111$cE3.1783@.clgrps12...
> I
> I
> next
> It's
>|||On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
wrote:
>But instead we see sp:cacheinsert event right after sp:cachemiss event. It'
s
>inserted into cache but from where? On which step did it get compiled?
>I'd be highly grateful for any information.
sp_recompile only marks the SP, it doesn't actually *do* the
compilation at that time, SQLServer "lazily" waits for the next call
for execution, and then compiles it.
J.|||JXStern wrote:
> On Thu, 25 Nov 2004 06:22:13 GMT, "Alex" <alex_remove_this_@.telus.net>
> wrote:
> sp_recompile only marks the SP, it doesn't actually *do* the
> compilation at that time, SQLServer "lazily" waits for the next call
> for execution, and then compiles it.
> J.
This "laziness" avoids unnecessary compilations.
However, there is also a technical reason that SP's are not recompiled
immediate after a schema change or sp_recompile. This is because the
compilation phase uses the stored procedure parameters so the most
representative statistics can be used, and thus will not 'guess'
parameter values. This basically means that SP's cannot be compiled
without calling them (with the appropriate parameters).
Gert-Jan|||Not quite.
The explanation of the terms is fine, but this is not how Profiler records
them.
If you actually look at what happens when you issue the sp_recompile, you'll
see a SP:CacheRemove event. Then the next time you call the proc, you'll see
SP:CacheInsert just as for the first time.
AFAIK, the SP:Recompile event is ONLY generated in the situation where a
stored procedure is recompiled while it is executing. This is caused by
activities in the sproc like DDL, updating statistics or changing a SET
option.
See KB 308737 for more details.
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23Wuoqeu0EHA.1392@.TK2MSFTNGP14.phx.gbl...
> Alex,
> The difference is in the difference between the words "compile" and
> "recompile". If you drop and
> create the proc, the proc plan doesn't exist and fir the first execution
> you get a compilation. Same
> if you empty the proc cache.
> However, if you sp_recompile a table that the proc is using, the plan is
> still in cache and for the
> next execution SQL Server will need to REcompile that plan.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Alex" <alex_remove_this_@.telus.net> wrote in message
> news:pSepd.2111$cE3.1783@.clgrps12...
>|||Thank you guys for all that information
Alex
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:41A77B97.DA602FD7@.toomuchspamalready.nl...
> JXStern wrote:
It's[vbcol=seagreen]
> This "laziness" avoids unnecessary compilations.
> However, there is also a technical reason that SP's are not recompiled
> immediate after a schema change or sp_recompile. This is because the
> compilation phase uses the stored procedure parameters so the most
> representative statistics can be used, and thus will not 'guess'
> parameter values. This basically means that SP's cannot be compiled
> without calling them (with the appropriate parameters).
> Gert-Jan
Subscribe to:
Posts (Atom)