Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

plant count really high-Activity Monitor Expand / Collapse
Author
Message
Posted Monday, December 3, 2012 8:21 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 8:50 AM
Points: 83, Visits: 219
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
Posted Monday, December 3, 2012 8:45 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Wednesday, November 19, 2014 5:22 AM
Points: 711, Visits: 2,209
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
Post #1391994
Posted Monday, December 3, 2012 8:59 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:31 PM
Points: 14,000, Visits: 28,381
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
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
Posted Monday, December 3, 2012 9:27 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 8:50 AM
Points: 83, Visits: 219
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
Posted Monday, December 3, 2012 9:41 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:31 PM
Points: 14,000, Visits: 28,381
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
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
Posted Monday, December 3, 2012 9:47 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 8:50 AM
Points: 83, Visits: 219
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
Posted Monday, December 3, 2012 10:46 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:31 PM
Points: 14,000, Visits: 28,381
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
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
Posted Monday, December 3, 2012 4:40 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 3:44 PM
Points: 2,266, Visits: 3,419
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)

Carl Sagan said: "There is no such thing as a dumb question." Sagan obviously never watched a congressional hearing!
Post #1392184
Posted Monday, December 3, 2012 6:13 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:31 PM
Points: 14,000, Visits: 28,381
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
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 »

Add to briefcase

Permissions Expand / Collapse