Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does DBCC DBREINDEX('?', ' ', 80) do?

What exactly does the following statement do? Does it reindex all tables named '?' with a fill factor of 80% ?

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

It did improve query time from 23 seconds to almost instantly but I'd like to understand why.

like image 408
Serve Laurijssen Avatar asked Aug 13 '13 08:08

Serve Laurijssen


People also ask

Does DBCC Dbreindex update statistics?

The statement Updates user-defined, auto-created statistics and it also updates the statistics associated with the index.

What is reindex in SQL Server?

REINDEX rebuilds an index using the data stored in the index's table, replacing the old copy of the index. There are several scenarios in which to use REINDEX: An index has become corrupted, and no longer contains valid data.

What are DBCC commands?

Microsoft SQL Server Database Console Commands (DBCC) are used for checking database integrity; performing maintenance operations on databases, tables, indexes, and filegroups; and collecting and displaying information during troubleshooting issues.


1 Answers

Not quite - when you use sp_MSforeachtable, the question mark is a placeholder for the the table name (as it loops through each table in turn).

In reply to your second question from the comments, yes - according to the documentation on DBCC DBREINDEX about the second argument:

If index_name is specified, table_name must be specified. If index_name is not specified or is " ", all indexes for the table are rebuilt.

like image 84
Bridge Avatar answered Oct 23 '22 20:10

Bridge