Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Creating Index take a long time Expand / Collapse
Author
Message
Posted Sunday, August 3, 2014 6:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 12:38 AM
Points: 110, Visits: 239
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
Post #1599027
Posted Sunday, August 3, 2014 11:40 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 4:15 PM
Points: 2,120, Visits: 3,202
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)

Carl Sagan said: "There is no such thing as a dumb question." Sagan obviously never watched a congressional hearing!
Post #1599065
Posted Sunday, August 3, 2014 1:15 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 8:49 AM
Points: 17,704, Visits: 15,565
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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1599069
Posted Sunday, August 3, 2014 7:28 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 12:38 AM
Points: 110, Visits: 239
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 ?

Post #1599099
Posted Sunday, August 3, 2014 7:35 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 12:38 AM
Points: 110, Visits: 239
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

Post #1599100
Posted Sunday, August 3, 2014 7:53 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 8:49 AM
Points: 17,704, Visits: 15,565
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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1599101
Posted Sunday, August 3, 2014 8:10 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 8:49 AM
Points: 17,704, Visits: 15,565
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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1599103
Posted Sunday, August 3, 2014 9:35 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 12:38 AM
Points: 110, Visits: 239
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 ?
Post #1599112
Posted Sunday, August 3, 2014 10:01 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 8:49 AM
Points: 17,704, Visits: 15,565
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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1599113
Posted Sunday, August 3, 2014 10:42 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 12:38 AM
Points: 110, Visits: 239
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 !
Post #1599115
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse