I have 8 billion records in my SQL Server table. I need to create an index on a couple of columns. I am sure that is going to take an unruly large amount of time.
Could somebody tell me a faster and better way of doing it?
I have 8 billion records in my SQL Server table. I need to create an index on a couple of columns. I am sure that is going to take an unruly large amount of time.
Could somebody tell me a faster and better way of doing it?
One option i could think of is SORT_IN_TEMPDB = ON.
which can help in creating index faster
The intermediate sort results that are used to build the index are stored in tempdb. This may reduce the time required to create an index if tempdb is on a different set of disks than the user database. However, this increases the amount of disk space that is used during the index build.
you could also try not querying the table so that there won't be any locking,blocking during creation of index or else use ONLINE = { ON | OFF }
based on your edition of sqlserver..
Also if your database is in simple recovery model,this operation is minimally logged which reduces IO..
It really shouldn't take that long to create indexes:
CREATE INDEX index_name
ON table_name (column1, column2, ...)