
Showing posts with label Maintenance. Show all posts
Showing posts with label Maintenance. Show all posts
SQL Statistics - Auto Create and Auto Update

DBCC CHECKDB and BACKUP with CHECKSUM

SQL Database Last Known Good DBCC CHECKDB
Database integrity check is one of the most important maintenance task in database. Most of the time, we either setup a maintenance plan or develop a custom script and scheduled it to run from SQL agent job. If we want to know if DBCC CHECKDB ran successfully, we can examine the Agent job history or log. But there is another (or better) way to look up when is the last time DBCC CHECKDB successfully ran.
DBCC SHRINKFILE TempDB
If you try to run DBCC SHRINKFILE command after a hung DBCC SHRINKFILE session (e.g. you cancel it in the middle of the shrink process) or you are shrinking the database in the middle of backup, you may receive this error message.
File ID of database ID cannot be shrunk as it is either being shrunk by another process or is empty
File ID of database ID cannot be shrunk as it is either being shrunk by another process or is empty
SQL Index Maintenance - Reorganize and Rebuild Index
SQL Server database indexes are created mainly to optimize performance. Different types of indexes such as clustered index, non-clustered index are put in place to make query process run faster. However over time, DML statements (insert, update, delete) cause information scattered across database hence resulting table or index fragmentation. Fragmentation happen when the data logical order does not match with physical ordering inside the data file. These fragmentation need to be addressed according as it could significantly affect SQL Server performance.
SQL Detect Fragmentation With DMV
Dynamic management view (DMV) sys.dm_db_index_physical_stats return size and fragmentation information for data and indexes for table and view. Here is some of the details about the DMV and the script I use to identify fragmentation.
Subscribe to:
Posts (Atom)