snippetsqlMinor
How to find what tables are stored in what data files
Viewed 0 times
storedtableshowwhatarefilesfinddata
Problem
I know that tables can span across multiple data files
The tables are already created. I did not create them myself. I'm trying to find out what table(s) are using the highest amount of IO. I was able to find out what data files are using high IO using the
Question : Is there a way to find out what files the tables are associated with?
The tables are already created. I did not create them myself. I'm trying to find out what table(s) are using the highest amount of IO. I was able to find out what data files are using high IO using the
sys.fn_virtualfilestats function. Question : Is there a way to find out what files the tables are associated with?
Solution
You can find directly which rowset (partition of an index/heap) belongs to which filegroup: look at
But I would encourage you to go down a different path. Specially in the light of your comment about correlating space used in the file with IO, since the largest file by size does not necessarily imply most IO in the file (think data at rest). Instead, use
data_space_id in sys.allocation_units. But is not going to give you details at the individual file-within-filegroup level. It is possible to find exactly how each rowset page lays out in each file by chasing the IAM chains manually, or by using undocumented features like DBCC IND or %%physloc%%. Not trivial, but possible.But I would encourage you to go down a different path. Specially in the light of your comment about correlating space used in the file with IO, since the largest file by size does not necessarily imply most IO in the file (think data at rest). Instead, use
sys.dm_db_index_usage_stats and, especially, sys.dm_db_index_operational_stats instead. You will get the load on each rowset, and then you can correlate this with the actual physical IO.Context
StackExchange Database Administrators Q#9086, answer score: 3
Revisions (0)
No revisions yet.