« Return of Expenses & Benefits – It’s not too late! | Main | Preparation for CIS Scheme »

July 06, 2006

Comments

Sam Gompels

Great to have some meaty technical tips on here. Keep them coming, we need some reminders of what needs looking after.

Jeff Maultby

Another way to do this but to all tables, resolve space fragementation at same time and force an update to db stats is:

sqlmaint -S LC21535 -U sa -P sa -D AccessJeff -RebldIdx 25 -UpdOptiStats 25

where LC21535 is Server name
sa is user name
sa is password
AccessJeff is database name
-RebldIdx is command to do indexes rebuild
25 is free space to allow for.
-UpdOptiStats is command to update stats
25 is sample size

Sam Gompels

Jeff's way looks to be better, rather than table by table - could Access confirm (maybe Jeff is Access!) that using these settings we could do the whole database at once and achieve the same result, is 25 correct for all tables ?.....or could it be added as a facility in data utilities for those of us who are a bit less technical.

Oliver Cox

Jeff's method is a more global approach to the topic and will certainly provide you with a quick & easy way to reindex your entire database using, what appears to be, a single command. It all depends on whether you have the time or the need to reindex everything or not.

Another way to do it would be to use the undocumented sp_MSforeachtable stored procedure which, as its name suggests, allows you to perform tasks across all tables in the database e.g.

EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', '', 0)"

Remember though, that the DBCC REINDEX command should be performed as an off-line operation and the more indexes you rebuild, the longer it will take.

The figure of 25% relates to the fill factor of data pages. To get the correct setting for each table/index is fairly tricky but what we are aiming for is optimum performance for both reads & writes. Getting an incorrect fill factor can degrade performance. It all depends on ratios of data reads & writes, what type of table it is i.e. lookup or transactional, database growth etc & also how often reindexing can be performed. With this in mind, setting a global fill factor of 75% (i.e. 25% free space) may not be the best option. In the T-SQL examples I have given, I have simply used a fill factor or 0 which points SQL Server to use default values & basically make its own mind up in terms of free space per data page. This does seem to be the recommended approach to follow and works well for us, especially as we have the ability to run reindexing routines on a weekly basis.

The comments to this entry are closed.

View blog reactions | Add to del.ico.us