Weird one.

  • Thread starter Thread starter Shawn
  • Start date Start date
S

Shawn

I have a dataset named "dsMessages" that has a single table. I have a timer
that runs a query against an SQL db every 5 seconds. At the beginning I have
it run dsMessages.Clear(). The first time this runs, it causes a long pause,
but then it runs fine every time thereafter. I have other datasets in the
application that seem to do the same thing... Any ideas?
 
It's likely the result of the way SQLS handles query execution plan
caching. The first time a query runs, it takes longer. Subsequent
executions are faster because the plan is reused. See the topic
"Execution Plan Caching and Reuse" in SQL Server Books Online for more
information. One workaround to avoid the first-time perf hit is on
startup to run those queries in the background so plans are cached and
available for reuse. This may or may not work depending on the type of
applicaton you have.

--Mary
 
Shawn said:
The first time this runs, it causes a long pause, but then it runs
fine every time thereafter. I have other datasets in the application
that seem to do the same thing...

As will just about every other, complex class you ever use or write
in .Net's Managed Code (although I'm surprised that /more/ than
one DataSet should do it in the same application).

It's because the first time you use any [method within a] class, the
RunTime has to go off, pull the relevant code out of the assembly,
and pop it through the Just-In-Time "Compiler" (actually, a Linker,
but what's in a name?) before it can actually execute it. Fortunately,
it only has to do this once for each method within any running process.

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top