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.
Author |
Topic |
MrBloom
Starting Member
36 Posts |
Posted - 2013-07-28 : 04:12:50
|
Hi I have a table with almost 3 billion records the are 4 columns ID (varchar), start (int), end(int), value (varchar)ID and start compounded together can make the record unique but ID can be a mix of alphanumerics so is set as a varchar. the main query I would like to run is fairly simple. SELECT ID, start, [end] , value FROM MYTable WHERE ID = 'somevalue' AND start >= someint and [end] <= someint This query is usually run through several times in a batch script where different ID, start and end values arepassed to the query and the results are selected into a temp table. I'm not sure about the best index to build on this table to make the query run the most efficiently. Whether to build a clustered or non clustered index on ID, start, end. Or even to reload the table with a unique identity column and partition on this. thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-28 : 11:46:27
|
Clustered on id,start,end combination should be enough------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
srimami
Posting Yak Master
160 Posts |
Posted - 2013-08-08 : 05:03:18
|
It depends on your where condition that is being used in queries. Visakhs's suggestion would work based on the query you provided but if other users are querying on Data Column then I would suggest you go with Clustered Index on Date column and NCL on remaining columns.Thanks,Sri. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-08 : 06:31:42
|
Creating a clustered index on a 3 billion row table will take time and a lot of log file space.At least 1.5-2 hours to complete.Which indexes do you already have on the table? Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
|
|
|
|
|