For a DBA its a routine issue to keep watch on the tables and database usage. Hence, it should be possible for any DBA to track the changes made to either a database or a table and be able to take necessary action according to the situation. Consider, if there is a database which is never used in a server but still there in the server. The metadata of the idle database will be stored in the system databases as this is connected to the server and if the database is very big with many objects, its obvious that a huge data should be stored in the system databases related to that database. Hence to counter the problem we can check the server databases which are critical in respect to its usage and if we found some databases never being used, we can take them offline. We can check the database, when it was last used or updated by running a query as shown below.
Note: This is valid only till the SQL Server session is open. If the server is once restarted, the table sys.dm_db_index_usage_stats looks empty.
To counter the above drawback, I am still working and update the same in the near future. I also wanted to know the number of times a database of a server is being used for a specified period, say a month. If someone have any suggestion please be kind enough to put on a comment.
select distinct DB_NAME(database_id), object_name(object_id), last_user_seek,last_user_scan, last_user_lookup, last_user_update
from
sys.dm_db_index_usage_stats
from
sys.dm_db_index_usage_stats
To counter the above drawback, I am still working and update the same in the near future. I also wanted to know the number of times a database of a server is being used for a specified period, say a month. If someone have any suggestion please be kind enough to put on a comment.
Comments
Post a Comment