Home > Archive > MS SQL Server > March 2005 > how to made adhoc query cached?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to made adhoc query cached?
Leo

2005-03-30, 9:40 am

Hi,
I have a problem with performance of ADHOC query like "exec sp_Name
par1=@par1 ... parN=@parN". I know that there are prox. 50 different kinds of
the query ( with different parameter value ). I found in syscacheobjects only
20% of cases. And most heavy query is not cached at all. The execution time
of this particular query is 10 times more than if it was cached. Do somebody
know how to made sqlserver to cache particular adhoc query?
Thanks.

Uri Dimant

2005-03-30, 9:40 am

Leo
Did you see an execution plan of the query? Did the optimizer
use any indexes defined on the tables?
How big are your tables?
How many rows do you want to retrieve?






"Leo" <Leo@discussions.microsoft.com> wrote in message
news:80BD14F0-FF7A-43C7-BBE6- F7C241889597@microso
ft.com...
> Hi,
> I have a problem with performance of ADHOC query like "exec sp_Name
> par1=@par1 ... parN=@parN". I know that there are prox. 50 different kinds

of
> the query ( with different parameter value ). I found in syscacheobjects

only
> 20% of cases. And most heavy query is not cached at all. The execution

time
> of this particular query is 10 times more than if it was cached. Do

somebody
> know how to made sqlserver to cache particular adhoc query?
> Thanks.
>



Leo

2005-03-30, 9:40 am

Of cource, I saw the plan under query analizer, and this plan quite satisfy me.
The problem is that the application sometimes use another plan. The query in
plan I see in QA uses tables indexes. The size is not very big - less than
100K records,
but query uses aggregations.


"Uri Dimant" wrote:

> Leo
> Did you see an execution plan of the query? Did the optimizer
> use any indexes defined on the tables?
> How big are your tables?
> How many rows do you want to retrieve?
>
>
>
>
>
>
> "Leo" <Leo@discussions.microsoft.com> wrote in message
> news:80BD14F0-FF7A-43C7-BBE6- F7C241889597@microso
ft.com...
> of
> only
> time
> somebody
>
>
>

Uri Dimant

2005-03-30, 9:40 am

Leo
So , does it meant that query optimizer was available to use indexes?
Can you post your query and how you call it ?



"Leo" <Leo@discussions.microsoft.com> wrote in message
news:B453A794-56BE-49AC-82E7- C117DDABC73E@microso
ft.com...
> Of cource, I saw the plan under query analizer, and this plan quite

satisfy me.
> The problem is that the application sometimes use another plan. The query

in[color=darkred]
> plan I see in QA uses tables indexes. The size is not very big - less than
> 100K records,
> but query uses aggregations.
>
>
> "Uri Dimant" wrote:
>
kinds[color=darkred]

syscacheobjects[colo
r=darkred]


Leo

2005-03-30, 9:40 am

It is nice of you , Uri to prompt me to find out the problems from source.
But I afraid it is impossible - the size of procedure is 17 kB and it is
really complicated :)
My question is how make sqlserver put the plan of this procedure to cache.
When I call dbcc freeproccache then call my procedure , it is goes to cache,
but after server restart and cache clearing it is disappiared. I need some
predictable behavior and want it always be in cache.

Thank you once more for assistance.

Leo

"Uri Dimant" wrote:

> Leo
> So , does it meant that query optimizer was available to use indexes?
> Can you post your query and how you call it ?
>
>
>
> "Leo" <Leo@discussions.microsoft.com> wrote in message
> news:B453A794-56BE-49AC-82E7- C117DDABC73E@microso
ft.com...
> satisfy me.
> in
> kinds
> syscacheobjects
>
>
>

Tibor Karaszi

2005-03-30, 9:40 am

You can create an autostart procedure from which you execute this stored procedure. See
sp_procoption.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/

http://www.sqlug.se/


"Leo" <Leo@discussions.microsoft.com> wrote in message
news:63F79347-2F0F-4F76-B318- 77C3AEC167B2@microso
ft.com...[color=darkred]
> It is nice of you , Uri to prompt me to find out the problems from source.
> But I afraid it is impossible - the size of procedure is 17 kB and it is
> really complicated :)
> My question is how make sqlserver put the plan of this procedure to cache.
> When I call dbcc freeproccache then call my procedure , it is goes to cache,
> but after server restart and cache clearing it is disappiared. I need some
> predictable behavior and want it always be in cache.
>
> Thank you once more for assistance.
>
> Leo
>
> "Uri Dimant" wrote:
>


Leo

2005-03-31, 7:01 am

Thanks

"Tibor Karaszi" wrote:

> You can create an autostart procedure from which you execute this stored procedure. See
> sp_procoption.
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www. solidqualitylearning
.com/

> http://www.sqlug.se/
>
>
> "Leo" <Leo@discussions.microsoft.com> wrote in message
> news:63F79347-2F0F-4F76-B318- 77C3AEC167B2@microso
ft.com...
>
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com