SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


NC Index Seek 51% and select cost 0%?


NC Index Seek 51% and select cost 0%?

Author
Message
SQL Galaxy
SQL Galaxy
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2630 Visits: 3465
Hi,

what could be issues, select command taking 50 sec for result..
as per actual Exec.plan dispaly NC Index Seek 51% and select cost 0%..

Pl. suggestion me..how to improve performance?

thanks
ananda
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91789 Visits: 45285
Core of your problem

Estimated rows 1
Actual rows 2887406

That's on the index seek for the REsult table. Probably stale or missing stats, could be parameter sniffing, without more details pretty hard to say.
Fix that and there's a far better chance of a suitable exec plan.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


SQL Galaxy
SQL Galaxy
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2630 Visits: 3465
thanks for reply... I got the result 00:00:00 seconds after update stats in NC Clustred Index in RESULT Table..
ChrisM@Work
ChrisM@Work
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: 17174 Visits: 19557
ananda.murugesan (7/14/2013)
thanks for reply... I got the result 00:00:00 seconds after update stats in NC Clustred Index in RESULT Table..



Can you post the actual plan?

Joins in the WHERE clause are not recommended, use ANSI joins instead. Your query can be rewritten like so:

SELECT 
s.SAMPLED_DATE ,
s.SAMPLE_NUMBER ,
sp.[DESCRIPTION] as SAMPLING_POINT ,
r.NAME as COMPONENT ,
t.TAG_NAME as IP21_TAG ,
r.NUMERIC_ENTRY as APPROVED_RESULT ,
u.DISPLAY_STRING as UOM
FROM [SAMPLE] s
INNER JOIN RESULT r
ON r.SAMPLE_NUMBER = s.SAMPLE_NUMBER

INNER JOIN OPC_TAG t
ON t.ANALYSIS = r.ANALYSIS
AND t.SAMPLING_POINT = s.SAMPLING_POINT

INNER JOIN SAMPLING_POINT sp
ON sp.NAME = t.SAMPLING_POINT

INNER JOIN UNITS u
ON u.UNIT_CODE = r.UNITS

WHERE t.OPC_SERVER = @0
AND s.SAMPLED_DATE > = DATEADD ( MM , @1 , GETDATE ( ) )
AND s.STATUS = @2
AND r.STATUS = @3
AND s.ALIQUOT_GROUP IS NULL



“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
SQL Galaxy
SQL Galaxy
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2630 Visits: 3465
I modified Query as per your suggestion and fetching result 00 seconds..But NC clustred index seek 50% and .. what could be issues?, Need to change index column? and all Inner Join seeks 0%

attched here actual plan
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91789 Visits: 45285
ananda.murugesan (7/15/2013)
But NC clustred index seek 50% and .. what could be issues?


And that's a problem why?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


SQL Galaxy
SQL Galaxy
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2630 Visits: 3465
Problem is need to check other table stats and will update it. not in RESULT table stats.

as per query that well parameterized and again index seek 50 %.. please explain me?
ChrisM@Work
ChrisM@Work
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: 17174 Visits: 19557
ananda.murugesan (7/15/2013)
I modified Query as per your suggestion and fetching result 00 seconds..But NC clustred index seek 50% and .. what could be issues?, Need to change index column? and all Inner Join seeks 0%

attched here actual plan


As Gail says, why should that be a problem? The costs are relative - you won't get them all down to 0%!!

The route taken by the optimiser to fetch rows from the RESULT table could be improved by using a covering index and by including a couple more keys. Try this:
create a new index on the RESULT table with keys SAMPLE_NUMBER, STATUS and ANALYSIS,
and included columns UNITS, NAME, NUMERIC_ENTRY. Then check the plan - the order of the keys is significant and is tricky to get right on the first attempt.

Edit - removed RESULTNUMBER, it's the cluster key.

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91789 Visits: 45285
ananda.murugesan (7/15/2013)
as per query that well parameterized and again index seek 50 %.. please explain me?


Well, the cost has to be somewhere. Percentages have to add to 100% or they're meaningless, so something has to have a non-zero cost percentage.

Is the query still a problem? If no, go find a query that is a problem and worry about that query.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91789 Visits: 45285
ChrisM@Work (7/15/2013)
Edit - removed RESULTNUMBER, it's the cluster key.


Why? What if someone changes the clustered index?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


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