473,804 Members | 3,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Indexes on Large Data Extract

3 New Member
Dear all,

I have a question regarding indexes on a data extract database we have - MSSQL2000.

Each night a scheduled job:

1. Deletes the indexes
2. Truncates the table data (empties the tables of all data)
3. Imports the latest data from a UNIX database
4. Recreates the indexes.

Q1. Is this the best way to deal with the indexes? I believe the deleting and recreating is causing a problem on the scheduled job but im not sure of the best way to set this up. Is there a command to rebuild them? Or will it simply do it itself?

The data imported is large amount, several million transactions in 1 table alone so the need for indexes is paramount.

Q2. Overall is this a good method to perform this extract?

Many thanks for any help.

Tim
Oct 22 '07 #1
3 1647
ashwingawande
7 New Member
Hi,

I think u can rebuilt the index instead of deleting and recreating it which of course affects adversly. The command to rebuild an index is : DBCC DBREINDEX. Also u need to check for Index fragmentation. As u have mentioned that ur volume of data is very high so continuously u need to keep an eye on index fragmentation and u need to DEFRAGMENT that index after every interval. To know about fragmentation details use this command :DBCC SHOW CONTIG and for defragmentation just rebuild the index. Also depending upon the frequency of inserts and updates in table u need to specify FILL FACTOR.

Hope this will help u.

Ashwin


Dear all,

I have a question regarding indexes on a data extract database we have - MSSQL2000.

Each night a scheduled job:

1. Deletes the indexes
2. Truncates the table data (empties the tables of all data)
3. Imports the latest data from a UNIX database
4. Recreates the indexes.

Q1. Is this the best way to deal with the indexes? I believe the deleting and recreating is causing a problem on the scheduled job but im not sure of the best way to set this up. Is there a command to rebuild them? Or will it simply do it itself?

The data imported is large amount, several million transactions in 1 table alone so the need for indexes is paramount.

Q2. Overall is this a good method to perform this extract?

Many thanks for any help.

Tim
Oct 22 '07 #2
Jim Doherty
897 Recognized Expert Contributor
Hi,

I think u can rebuilt the index instead of deleting and recreating it which of course affects adversly. The command to rebuild an index is : DBCC DBREINDEX. Also u need to check for Index fragmentation. As u have mentioned that ur volume of data is very high so continuously u need to keep an eye on index fragmentation and u need to DEFRAGMENT that index after every interval. To know about fragmentation details use this command :DBCC SHOW CONTIG and for defragmentation just rebuild the index. Also depending upon the frequency of inserts and updates in table u need to specify FILL FACTOR.

Hope this will help u.

Ashwin
In addition check your database recovery model if it is 'Full Recovery' then for merely importing a huge dataset you might want to consider changing it to Bulk Logged for the period of time it is importing (to reduce process and thereby restrict the growth your transaction log

(database node in EM right click properties...re covery model)


Heres a stored procedure you might want to check out to set as a job to reindex all tables that currently have indexes. You can pass into this the fillfactor if you need to that is as a parameter

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE PROCEDURE dbo.usp_RebuildAllIndexes (
  3. @dbname sysname = null,
  4. @fillfactor tinyint = null
  5. )
  6. AS
  7. DECLARE @execstr nvarchar(255)
  8. SET NOCOUNT ON
  9. IF @dbname IS NULL SELECT @dbname = DB_NAME()
  10. IF @fillfactor IS NULL
  11.     SELECT @execstr = 'EXEC ' + @dbname + '..sp_MSforeachtable @command1="print ''?'' DBCC DBREINDEX (''?'')"'
  12. ELSE
  13.     SELECT @execstr = 'EXEC ' + @dbname + '..sp_MSforeachtable @command1="print ''?'' DBCC DBREINDEX (''?'','''',' + str(@fillfactor) + ')"'
  14. EXEC(@execstr)
  15. GO
  16.  

Regards

Jim
Oct 22 '07 #3
tim999
3 New Member
Many thanks for your replies guys.

I need to do some reading into the fill factor aspect but the rebuild command sounds much neater than a script that deletes and then recreates the indexes.

In addition check your database recovery model if it is 'Full Recovery' then for merely importing a huge dataset you might want to consider changing it to Bulk Logged for the period of time it is importing (to reduce process and thereby restrict the growth your transaction log

(database node in EM right click properties...re covery model)


Heres a stored procedure you might want to check out to set as a job to reindex all tables that currently have indexes. You can pass into this the fillfactor if you need to that is as a parameter

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE PROCEDURE dbo.usp_RebuildAllIndexes (
  3. @dbname sysname = null,
  4. @fillfactor tinyint = null
  5. )
  6. AS
  7. DECLARE @execstr nvarchar(255)
  8. SET NOCOUNT ON
  9. IF @dbname IS NULL SELECT @dbname = DB_NAME()
  10. IF @fillfactor IS NULL
  11.     SELECT @execstr = 'EXEC ' + @dbname + '..sp_MSforeachtable @command1="print ''?'' DBCC DBREINDEX (''?'')"'
  12. ELSE
  13.     SELECT @execstr = 'EXEC ' + @dbname + '..sp_MSforeachtable @command1="print ''?'' DBCC DBREINDEX (''?'','''',' + str(@fillfactor) + ')"'
  14. EXEC(@execstr)
  15. GO
  16.  

Regards

Jim
Oct 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4367
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have to code a solution to this it'll probably be done in ASP on a web server, unless there's a significantly better way. I'm looking for a way to create over 100 Excel *charts* programmatically.
5
3204
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have to code a solution to this it'll probably be done in ASP on a web server, unless there's a significantly better way. I'm looking for a way to create over 100 Excel *charts* programmatically.
2
5138
by: Ryan | last post by:
In oracle you rarely need to rebuild indexes no matter whether you do massive inserts or deletes. Does the same hold true in sql server?
1
2277
by: Steve_CA | last post by:
Hi, The more I read, the more confused I'm getting ! (no wonder they say ignorance is bliss) I just got back from the bookstore and was flipping through some SQL Server Administration books. One says, that to get the best query performance, youi do two things:
9
1901
by: pheonix1t | last post by:
hello, I've been assigned to do performance tuning on an SQL2000 database (around 10GB in size, several instances). So far, I see a single RAID5 array, 4CPU (xeon 700MHZ), 4GB RAM. I see the raid5 as a bottleneck. I'd setup a raid 10 and seperate the logs, database and OS(win2k). The one thing that was a bit odd to me was that I was told this place doesn't use indexes. The company is a house builder. They are pretty
16
2145
by: romicva | last post by:
I've recently upgraded from 8.1.4 to 8.2.3. System slowed down noticably. Explain shows that indexes are not used. I did reorgs on indexes and tables, collected stats on key fields with detail sample for all indexes with no improvement. Any help would be greatly appretiated. Thank you in advance.
2
8432
by: David Garamond | last post by:
I was thinking on how one would design an optimal (performance-wise) database of large number of schedules with crontab-like semantic. There will potentially be hundreds of thousands or even millions of "crontab" entries, and there will be a query run once every minute to determine which entries are to be run for that minute. The primary goal is, of course, for the query to run as fast as possible. My first stab is, straightforward...
22
1779
by: Zamdrist | last post by:
I am tasked with maintaining a large database still on SQL Server 7.0. Performance is an issue not surprisingly and I've targeted two rather large tables to see what I can do with the indexes. The 2 tables are described as follows: MatterConflicts: Fields: MatterConflicts varchar(16), Matters varchar(16), HitMatters varchar(16), IsInclude varchar(1) Index: MatterConflicts
0
7603
MMcCarthy
by: MMcCarthy | last post by:
The more data you include in your tables the more you will need to have indexes to search and sort that data. However, there is a balance between having enough indexes and too many. Too many indexes will slow down the speed of updates on your records. Access presets a number of Indexes for you. If you look in Tools ... Options under the Tables/Queries tab you will see that under "Auto Index on Import/Create" there is a list as follows: ...
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.