Solved

SQL CLR Slow at first start

Posted on 2010-09-02
3
914 Views
Last Modified: 2012-05-10
When I execute and SQL CLR store procedure, the first time .... it is really slow and then faster the second time. Is there a way to maintain this fast without having to trigger the storeprocedure every 1 minute?
0
Comment
Question by:ismamicrosolutions
  • 2
3 Comments
 
LVL 24

Expert Comment

by:DBAduck - Ben Miller
ID: 33593447
The reason is because the CLR is Common Language Runtime and is hosted by SQL Server.  It still follows the model of CLR applications in that it is compiled down to IL (Intermediate Language) and in order to execute must use a process called JIT (Just in Time) compiling to get to bytecode or executable code.  This is done once at the beginning of the first execution and from then on uses the bytecode produced.  

So in any CLR or .NET language, you will incur the cost of the JIT on the first invocation.  This is what you are seeing.

Also note that this only happens when the AppDomain is recycled, which is governed by the CLR and I am not sure how often that happens in SQL.
0
 

Author Comment

by:ismamicrosolutions
ID: 33593467
But is there a way to bypass just in time or insert it as a more native language so no JIT need?
0
 
LVL 24

Accepted Solution

by:
DBAduck - Ben Miller earned 500 total points
ID: 33593478
Not that I am aware of.  You will load the assembly with CREATE ASSEMBLY and in the validation it checks the MSIL.

So I am not aware of a way to create an assembly that has been NGEN'd to bytecode.  It will always JIT.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now