Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
plant count really high-Activity Monitor
plant count really high-Activity Monitor
Rate Topic
Display Mode
Topic Options
Author
Message
sql007
sql007
Posted Monday, December 03, 2012 8:21 AM
Valued Member
Group: General Forum Members
Last Login: 2 days ago @ 2:24 PM
Points: 65,
Visits: 132
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
Post #1391971
s_osborne2
s_osborne2
Posted Monday, December 03, 2012 8:45 AM
SSChasing Mays
Group: General Forum Members
Last Login: Today @ 6:02 AM
Points: 618,
Visits: 1,878
Could that query form part of a stored procedure that has a RECOMPILE hint either for the whole proc, or just that statement itself?
MCSA: SQL Server 2012
Follow me on Twitter:
@WazzTheBadger
LinkedIn Profile:
Simon Osborne
Post #1391994
Grant Fritchey
Grant Fritchey
Posted Monday, December 03, 2012 8:59 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 6:02 AM
Points: 13,382,
Visits: 25,177
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1392011
sql007
sql007
Posted Monday, December 03, 2012 9:27 AM
Valued Member
Group: General Forum Members
Last Login: 2 days ago @ 2:24 PM
Points: 65,
Visits: 132
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
Post #1392024
Grant Fritchey
Grant Fritchey
Posted Monday, December 03, 2012 9:41 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 6:02 AM
Points: 13,382,
Visits: 25,177
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1392037
sql007
sql007
Posted Monday, December 03, 2012 9:47 AM
Valued Member
Group: General Forum Members
Last Login: 2 days ago @ 2:24 PM
Points: 65,
Visits: 132
I am looking at the acitvity monitor...recent queries...plan count...I am assuming its the number of plans cached...can someone confirm?...
Post #1392040
Grant Fritchey
Grant Fritchey
Posted Monday, December 03, 2012 10:46 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 6:02 AM
Points: 13,382,
Visits: 25,177
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1392064
ScottPletcher
ScottPletcher
Posted Monday, December 03, 2012 4:40 PM
Ten Centuries
Group: General Forum Members
Last Login: 2 days ago @ 3:56 PM
Points: 1,324,
Visits: 1,778
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)
One man with courage makes a majority. Andrew Jackson
Post #1392184
Grant Fritchey
Grant Fritchey
Posted Monday, December 03, 2012 6:13 PM
SSChampion
Group: General Forum Members
Last Login: Today @ 6:02 AM
Points: 13,382,
Visits: 25,177
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1392207
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.