Monday, April 3, 2023

MS-SQL Server - Index Update

Index Update


There are Different ways to Update Statistics.

Alter Index
DBCC DBREINDEX
Update Statistics

Below is the query to find when the last Stats/Index was updated.

SELECT object_schema_name(s.object_id) AS Object_Schema_Name,
    object_name(s.object_id) AS Object_Name,
    i.name AS Index_Name,
    STATS_DATE(s.object_id, s.stats_id) AS Stats_Last_Update
FROM sys.stats s
JOIN sys.indexes i
    ON s.object_id = i.object_id
    AND s.name = i.name

https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-index-transact-sql?view=sql-server-ver16

https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-dbreindex-transact-sql?view=sql-server-ver16

Additionally,

1. When my Backup Log size in GB, no need to worry...

- First thing that after the log backup, it gets truncated by itself.

- Secondly, we can change the Database Recovery Model to Simple to avoid log Space Full. If in case my Database does not require Point-in-time recovery.

2. There are maximum 4 digits/bytes limit in ID int column.


Best Regards


T. Amit Vaid S.

No comments: