Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple Indexes or Index with Multiple Column

Author  Topic 

Ghanta
Yak Posting Veteran

96 Posts

Posted - 2011-06-10 : 15:50:02
I need to run an update on a huge table using data from another table... tables are joined using 4 columns on each. Should I create one Index using all those columns or is it efficient to create separate indexes ... one for each column?

To give you the idea of number of records in those tables:
Table to be updated has 506242508 records
Table used to update has 5015556 records

Thanks in advance for help.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-10 : 15:56:07
One index

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-10 : 15:57:35
One index of 4 columns, although I doubt it will help with the number of rows you're updating. Since you're doing an update it will have to scan the table anyway.

Go to Top of Page

Ghanta
Yak Posting Veteran

96 Posts

Posted - 2011-06-10 : 16:03:57
Thanks a lot.
quote:
Originally posted by tkizer

One index

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page

Ghanta
Yak Posting Veteran

96 Posts

Posted - 2011-06-10 : 16:05:16
Rob I am thinking of doing it in batches of 5000 records? What do you think is a better solution? Thanks!
quote:
Originally posted by robvolk

One index of 4 columns, although I doubt it will help with the number of rows you're updating. Since you're doing an update it will have to scan the table anyway.



Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-10 : 16:08:03
Hard to say, my suggestion is to try it and see what happens.
Go to Top of Page

Ghanta
Yak Posting Veteran

96 Posts

Posted - 2011-06-10 : 16:11:00
Thank you.
quote:
Originally posted by robvolk

Hard to say, my suggestion is to try it and see what happens.

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-06-10 : 16:41:30
http://sqlinthewild.co.za/index.php/2010/09/14/one-wide-index-or-multiple-narrow-indexes/

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -