How to Determine Read Intensive and Write Intensive Tables in SQL Server? – Interview Question of the Week #251

Question: How can you identify tables with mostly read or write activity? The index-usage DMV gives a useful starting point, but its counters measure index operations, not rows or physical I/O.

A settled bookcase and a mobile bookcase suggest different patterns of access and change

A client asked this during a health check. I had used an activity script for other clients and shared it with them. The original four-column summary is still useful when you understand what its totals represent.

SELECT sc.name AS SchemaName, t.name AS TableName,
       SUM(s.user_seeks + s.user_scans + s.user_lookups) AS Reads,
       SUM(s.user_updates) AS Writes
FROM sys.dm_db_index_usage_stats AS s
JOIN sys.tables AS t ON t.object_id = s.object_id
JOIN sys.schemas AS sc ON sc.schema_id = t.schema_id
WHERE s.database_id = DB_ID()
GROUP BY sc.name, t.name
ORDER BY Reads DESC, Writes DESC;
Original fourcolumn activity result lists TransactionHistory Reads4 Writes1 and Person Reads1 Writes0
The historical sample has the same four columns. These are activity counters from that run, not values to expect on your server.

Reads sums seeks, scans and lookups across the table’s index entries. Writes sums user_updates across those entries. One statement updating a thousand rows can increment a given index’s update counter once; maintaining several indexes can contribute several increments to this table-level sum.

That makes Writes an index-maintenance activity total, not a count of distinct write statements. Reads isn’t a count of rows, pages read or physical disk operations either. Don’t turn this quick ranking into a precise read/write percentage for an application.

The counters reset on an engine restart and can disappear for other database lifecycle events. A table with no DMV entry isn’t represented here; that is not proof it will never be used. Collect snapshots over a representative business interval, including less frequent reporting, and compare deltas before changing indexes or classifying a table permanently.

I kept the original output because the four columns make the answer tangible. The query now joins the current database’s catalog explicitly, while keeping its original activity calculation and names.

Previous question: an INNER JOIN that produces a Cartesian product.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL DMV, SQL Scripts, SQL Server
Previous Post
How to Write INNER JOIN Which is Actually CROSS JOIN? – Interview Question of the Week #250
Next Post
How to Disable Batch Mode in SQL Server? – Interview Question of the Week #252

Related Posts

2 Comments. Leave new

  • Thanks for the script. I ran it but I don’t know how to interpreted it.
    This is my top 3:
    Reads Writes
    612.378 450.830
    326.989 155.881
    31.597 9.541

    Should I worry?

    Reply
  • Pinal,

    Thanks for this script and many other scripts !!! Your contribution to the sql server community is priceless- It is great to have people like you in our community.

    @Paul Meems- This query gives you an idea how your indexes are being used- whether you are writing more on the indexed table or reading more from the indexes .Obviously If you have more writes than reads and if table has lots of indexes then performance may suffer. I have used this script in our environment and it helped us a lot in identifying the write intensive indexed tables.

    Regarding your question- cannot say for sure whether you should worry or not- Are these three read/writes are from the same table? I would suggest you to run the “3 free scripts to instantly improve SQL Server Performance” that Pinal offers and see for yourself what action can you take to improve the performance of indexes.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.