Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


plant count really high-Activity Monitor


plant count really high-Activity Monitor

Author
Message
sql007
 sql007
SSC Journeyman
SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)

Group: General Forum Members
Points: 84 Visits: 234
Hi
I am new to the DBA side, but activity montior shows a high plan clount of 23438

The query that an application runs is :


SELECT *
FROM Trans_Events
WHERE iTrans_fk = 1604855

Itrans_fk is non-clustered index and no fragmentation on the table.

can anyone point me in the right direction?
Thanks
s_osborne2
s_osborne2
Right there with Babe
Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)

Group: General Forum Members
Points: 745 Visits: 2292
Could that query form part of a stored procedure that has a RECOMPILE hint either for the whole proc, or just that statement itself?



MCSE: Data Platform
MCSE: Business Intelligence
Follow me on Twitter: @WazzTheBadger
LinkedIn Profile: Simon Osborne
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17629 Visits: 32268
I'm a little confused by the question. When you say "high plan count" do you mean the number of plans in cache is high? If that's right, how are you establishing a low & high number there. Do you have a baseline.

Or, do you mean that the query is running long? If so, you need to look at the execution plan to understand whether or not it's selecting the index that you have. Also, since you're doing a SELECT * and you're going against a non-clustered index, you're going to be seeing RID or key lookups (depending on if you're dealing with a heap or a clustered index).

Or, do you mean that the estimated rows is high? If so, you need to update your statistics.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
sql007
 sql007
SSC Journeyman
SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)

Group: General Forum Members
Points: 84 Visits: 234
It is a query that is running not a store proc, but runs very often.....The table does have a clustered index, but the search is done on a non-clustered index...I got the plan count from activity monitor>Recent Expensive Queries

Update stats is auto on the DB

I dont have a baseline but isn't 23000+ a really high plan count. The query executes within a second.

Maybe I need a better understanding of plan counts, can you please explan?
Thanks
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17629 Visits: 32268
I'm still confused. Is that 23,000 executions of a query, or 23,000 different query plans of a query? You keep saying "plan count" and that's where my confusion lies. If it's 23,000 plans, you have some major issues.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
sql007
 sql007
SSC Journeyman
SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)

Group: General Forum Members
Points: 84 Visits: 234
I am looking at the acitvity monitor...recent queries...plan count...I am assuming its the number of plans cached...can someone confirm?...
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17629 Visits: 32268
Yes, that's an indication that you're probably using dynamic or ad hoc queries and every single variation of the parameter values is resulting in a different execution plan. That's really, really, bad. You're going to be hurting seriously with regards to memory and plan caching. You need to look at parameterizing the query in order to avoid this issue. That can be done by executing it using sp_executesql or by using prepared statements from your code or by creating a stored procedure.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
ScottPletcher
ScottPletcher
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3950 Visits: 6686
Hmm, something seems odd.

SQL should be able to easily do "simple parameterization" -- the old name, "auto-parameterization", seems clearer to me -- on that query. That is, SQL should automatically convert the query to make the value in the WHERE clause a parameter so a shareable plan is created.

Are you changing the case (upper/lower) of the query each time?(??)

Or making some other noticeable change to the query each time?

SQL DBA,SQL Server MVP('07, '08, '09)

Prosecutor James Blackburn, in closing argument in the "Fatal Vision" murders trial: "If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them."
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17629 Visits: 32268
ScottPletcher (12/3/2012)
Hmm, something seems odd.

SQL should be able to easily do "simple parameterization" -- the old name, "auto-parameterization", seems clearer to me -- on that query. That is, SQL should automatically convert the query to make the value in the WHERE clause a parameter so a shareable plan is created.

Are you changing the case (upper/lower) of the query each time?(??)

Or making some other noticeable change to the query each time?


But if there were significant changes then it's likely the hash for the query (which is what this must be using) would be different. They're the same.

You could try forced parameterization. You could also try using Optimize for Ad Hoc. You certainly sound like a candidate.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search