Index Usage

 SELECT i.name AS IndexName,
            OBJECT_NAME(i.object_id) AS TableName,
            i.type_desc AS IndexType,
            s.user_seeks,
            s.user_scans,
            s.user_lookups,
            s.user_updates,
            s.last_user_seek,
            s.last_user_scan,
            s.last_user_lookup,
            s.last_user_update
FROM sys.indexes AS i
JOIN sys.dm_db_index_usage_stats AS s ON i.object_id = s.object_id AND i.index_id = s.index_id
WHERE OBJECTPROPERTY(i.object_id, 'IsUserTable') = 1
            AND s.database_id = DB_ID()
ORDER BY s.last_user_seek DESC;

  • last_user_seek: เวลาที่ Index ถูกใช้สำหรับการ Seek ล่าสุด
  • last_user_scan: เวลาที่ Index ถูกใช้สำหรับการ Scan ล่าสุด
  • last_user_lookup: เวลาที่ Index ถูกใช้สำหรับการ Lookup ล่าสุด
  • last_user_update: เวลาที่ Index ถูก Update ล่าสุด
  • Comments

    Popular posts from this blog

    การตั้งเวลาระหว่าง Server และ Client

    วิธีตั้งค่า NTP บน Primary Domain Controller

    ตรวจสอบ Version และ Service Pack ของ SQL Server