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


Primary Key Vs Clustered Index: Performance Tuning


Primary Key Vs Clustered Index: Performance Tuning

Author
Message
spaghettidba
spaghettidba
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5730 Visits: 13305
I think you should try to filter as much as possible the input with an appropriate index, and then join the correlated table.
Given that usually the primary key is the best possible clustered index, I would work on the nonclustered index side.
However, I see that you're selecting out a lot of columns from table "A", so that the optimizer could decide to avoid CI lookups and use the clustered index directly. I don't have your data volumes in place, I can't say without testing.

However, based on your query, I would try to see if a couple of NC Indexes can help.
I would create these two:

-- NC Index on Table A
-- KEY COLUMNS:
A.ProfileName
A.DomainName
A.TaskId
A.BookName
A.RunVersion
-- INCLUDE COLUMNS:
A.ProductType
A.PayReceive

-- NC Index on Table B
-- KEY COLUMNS:
B.RunVersion
B.COBDate
--INCLUDE COLUMNS:
B.Side
B.Currency
B.PaynonPVaccrual
B.Notional
B.RecnonPVaccrual
B.Mtm3



Also, you could transform the expression on the COBDate as follows:

--AND CONVERT(VARCHAR, B.COBDate, 112) = '20101116'
AND B.COBDate = CONVERT(datetime, '20101116',112)



Hope this helps. This is the best I can do from here.
Gianluca

--
Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
iamanks
iamanks
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 101
Thanks mate. Seems promising. Will try and let you know. However, the sizes of both tables I've already mentioned in earlier posts. Both Table A and B contains around 6.5 Million records.
spaghettidba
spaghettidba
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5730 Visits: 13305
ankit.dhasmana (12/22/2010)
Both Table A and B contains around 6.5 Million records.


I see. However I have no clue of how the optimizer will decide to work with the new indexes, beacause I'm working on empty tables.

--
Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
iamanks
iamanks
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 101
I'll check and surely let you know the outcome....
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