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


Creating Index take a long time


Creating Index take a long time

Author
Message
WhiteLotus
WhiteLotus
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2810 Visits: 971
Hi All,

I have just created 1 index in a large database ( 172 million rows ) in the testing server ...It took around 8 hours to complete which is very long time ...
Now I want to implement it in the production because it can speed up the query significantly.
the problem is I am worried that it will take a long time too in the production ( the database in the production has less rows which is 33 million rows ) but however it is still a big database.
I am using SQL standard so it would be impossible to Create index ONLINE..
Any solution please?

THanks so much !!

Cheers
ScottPletcher
ScottPletcher
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19801 Visits: 7412
8 hours seems extraordinarily extreme for 172M rows. It seems like there must be more to the story.

Are you changing the clustered index on the table? Does the table have other indexes?

SQL DBA,SQL Server MVP(07, 08, 09) Prosecutor James Blackburn, in closing argument in the Fatal Vision murders trial:
If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them.
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67189 Visits: 18570
Did you check the status of the index creation while in progress? Did you check for blocking?

Does the dev server have just a small amount of RAM or little cpu power?

Those things can affect the creation of the index.

Besides the 172million records, we know so little about your table. Things like total size of the table, data types, what the index was that you created. Those things can also impact the creation time.

Run the script from the following link and post the results for the table in question. Also post things like the table definition and index definition please.

http://bit.ly/tablespace



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

WhiteLotus
WhiteLotus
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2810 Visits: 971
ScottPletcher (8/3/2014)
8 hours seems extraordinarily extreme for 172M rows. It seems like there must be more to the story.

Are you changing the clustered index on the table? Does the table have other indexes?


hmm I never change anything before ..

yes the table has 5 other indexes...

atm the page count of that index is 788.162 and other indexes also have high page count ...

is that because of the large table or because of high page split ?
WhiteLotus
WhiteLotus
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2810 Visits: 971
SQLRNNR (8/3/2014)
Did you check the status of the index creation while in progress? Did you check for blocking?

Does the dev server have just a small amount of RAM or little cpu power?

Those things can affect the creation of the index.

Besides the 172million records, we know so little about your table. Things like total size of the table, data types, what the index was that you created. Those things can also impact the creation time.

Run the script from the following link and post the results for the table in question. Also post things like the table definition and index definition please.

http://bit.ly/tablespace



the dev server has only 4 CPU with 8 GB of RAM
but the production has 24 CPU with 32 GB of RAM

How do i check the blocking when I run the index creation process?

Data for the table :

Index space : 32.067.563 MB
Row count : 178.432.356 MB
Data space : 10.905.453 MB


The index :

CREATE NONCLUSTERED INDEX [IX_D] ON [dbo].[D]
(
[TemplateId] ASC
)
INCLUDE ( [Value],
[Datestamp])


FYI :

Template id (int)
Value (varchar(2000)
datestamp (datetime )

Unfortunately when I run the script that u gave me ..I got many errors but i hope the table profile that I give you can give you more information

looking forward your response

thankss
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67189 Visits: 18570
WhiteLotus (8/3/2014)
SQLRNNR (8/3/2014)
Did you check the status of the index creation while in progress? Did you check for blocking?

Does the dev server have just a small amount of RAM or little cpu power?

Those things can affect the creation of the index.

Besides the 172million records, we know so little about your table. Things like total size of the table, data types, what the index was that you created. Those things can also impact the creation time.

Run the script from the following link and post the results for the table in question. Also post things like the table definition and index definition please.

http://bit.ly/tablespace



the dev server has only 4 CPU with 8 GB of RAM
but the production has 24 CPU with 32 GB of RAM

How do i check the blocking when I run the index creation process?

Data for the table :

Index space : 32.067.563 MB
Row count : 178.432.356 MB
Data space : 10.905.453 MB


The index :

CREATE NONCLUSTERED INDEX [IX_D] ON [dbo].[D]
(
[TemplateId] ASC
)
INCLUDE ( [Value],
[Datestamp])


FYI :

Template id (int)
Value (varchar(2000)
datestamp (datetime )

Unfortunately when I run the script that u gave me ..I got many errors but i hope the table profile that I give you can give you more information

looking forward your response

thankss



It looks like you have a lot of off row data involved in that index creation. Looks to be a large index on a machine with little resources.

As per the other script, it looks like the update to the code engine converted > to gt and < to lt in the code. That would be the cause for the errors you are seeing. I am looking for a fix for that code prettifier to fix it.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67189 Visits: 18570
WhiteLotus (8/3/2014)
SQLRNNR (8/3/2014)
Did you check the status of the index creation while in progress? Did you check for blocking?

Does the dev server have just a small amount of RAM or little cpu power?

Those things can affect the creation of the index.

Besides the 172million records, we know so little about your table. Things like total size of the table, data types, what the index was that you created. Those things can also impact the creation time.

Run the script from the following link and post the results for the table in question. Also post things like the table definition and index definition please.

http://bit.ly/tablespace


Unfortunately when I run the script that u gave me ..I got many errors but i hope the table profile that I give you can give you more information




Script fixed and download option added.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

WhiteLotus
WhiteLotus
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2810 Visits: 971
SQLRNNR (8/3/2014)
WhiteLotus (8/3/2014)
SQLRNNR (8/3/2014)
Did you check the status of the index creation while in progress? Did you check for blocking?

Does the dev server have just a small amount of RAM or little cpu power?

Those things can affect the creation of the index.

Besides the 172million records, we know so little about your table. Things like total size of the table, data types, what the index was that you created. Those things can also impact the creation time.

Run the script from the following link and post the results for the table in question. Also post things like the table definition and index definition please.

http://bit.ly/tablespace


Unfortunately when I run the script that u gave me ..I got many errors but i hope the table profile that I give you can give you more information




Script fixed and download option added.


Oh thanks ..Thats kind of you .
It works now and here is the profile of that table :

ObjName SchemaName IsMsShipped NumRows ReservedPageMB DataSizeMB IndexSizeMB UnusedSpace dbsizeMB LogSizeMB TotalTableFreeSpace DataFileFreeSpace PercentofDBPhysFile PercentofDBUsedSpace
Table A dbo NO 178455184 10909.7109375 10907.101562 32079.750000 10.1875000 43430.00 1985.00 11.5468750 422.9296875 98.979600 99.005900


Btw TotalTableFreeSpace is in GB ?
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67189 Visits: 18570
Ok, that tells a tale of a much smaller table than what you were showing before.

I bet there was blocking, or memory thrashing, or slow io, or any number of issues that could crop up due to resource use while trying to create that index.

You can use sp_who2 as a quick means to identify blocking on a query such as creating an index.

The total free space (from that query) is in MB.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

WhiteLotus
WhiteLotus
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2810 Visits: 971
SQLRNNR (8/3/2014)
Ok, that tells a tale of a much smaller table than what you were showing before.

I bet there was blocking, or memory thrashing, or slow io, or any number of issues that could crop up due to resource use while trying to create that index.

You can use sp_who2 as a quick means to identify blocking on a query such as creating an index.

The total free space (from that query) is in MB.


I am running the creation of index and running SPwho2 as well

I notice there is 1 record has a profile as below :

SPID Status Login HostName BlkBy DBName Command CPUTime DiskIO LastBatch ProgramName SPID REQUESTID

172 SUSPENDED dgcLogin TST1-VW 156 DB1 INSERT 15 29041 08/04 14:31:57 .Net SqlClient Data Provider 172 0


The database that I am creating the index is DB1 ..so it seems it is blocked by INSERT process ??
How we overcome that ?

thanks !
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