Does STATISTICS IO output include Version Store reads?TempDB Version Store cleanupPhantom Transactions using Version Store in tempDBQuery plan reads vs statistics io readsCan I Improve Performance on Bloated System Tables?Clustered Index Scan when using greater than in WHERE clauseHelpful nonclustered index improved the query but raised logical readsA Query in the Query Store shows high Logical ReadsQuestions about the output of “statistics IO”IO Statistics for Index Seeklogical reads on global temp table, but not on session-level temp table

Why does the painters tape have to be blue?

How to find sum of maximum K elements in range in array

What is the limit to a Glyph of Warding's trigger?

How can I get a refund from a seller who only accepts Zelle?

How to deceive the MC

Storing voxels for a voxel Engine in C++

How to write numbers and percentage?

Python script to extract text from PDF with images

What did the 'turbo' button actually do?

How did the Allies achieve air superiority on Sicily?

What did Brienne write about Jaime?

Align vertices between two edges

Determine direction of mass transfer

How does Dreadhorde Arcanist interact with split cards?

Why is this integration method not valid?

The disk image is 497GB smaller than the target device

Complications of displaced core material?

What could be my risk mitigation strategies if my client wants to contract UAT?

Is superuser the same as root?

Status of proof by contradiction and excluded middle throughout the history of mathematics?

Could a rotating ring space station have a bolo-like extension?

Why is the Eisenstein ideal paper so great?

Why isn't Tyrion mentioned in 'A song of Ice and Fire'?

Was this scene in S8E06 added because of fan reactions to S8E04?



Does STATISTICS IO output include Version Store reads?


TempDB Version Store cleanupPhantom Transactions using Version Store in tempDBQuery plan reads vs statistics io readsCan I Improve Performance on Bloated System Tables?Clustered Index Scan when using greater than in WHERE clauseHelpful nonclustered index improved the query but raised logical readsA Query in the Query Store shows high Logical ReadsQuestions about the output of “statistics IO”IO Statistics for Index Seeklogical reads on global temp table, but not on session-level temp table






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








9















SQL Server has an option SET STATISTICS IO ON that shows the number of logical and physical page reads for a query. Do these stats include reads of the version store for SNAPSHOT and RCSI queries?










share|improve this question






























    9















    SQL Server has an option SET STATISTICS IO ON that shows the number of logical and physical page reads for a query. Do these stats include reads of the version store for SNAPSHOT and RCSI queries?










    share|improve this question


























      9












      9








      9








      SQL Server has an option SET STATISTICS IO ON that shows the number of logical and physical page reads for a query. Do these stats include reads of the version store for SNAPSHOT and RCSI queries?










      share|improve this question
















      SQL Server has an option SET STATISTICS IO ON that shows the number of logical and physical page reads for a query. Do these stats include reads of the version store for SNAPSHOT and RCSI queries?







      sql-server tempdb-version-store






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 9 at 12:07









      Paul White

      55.3k14291463




      55.3k14291463










      asked May 9 at 2:50









      ForrestForrest

      2,8101824




      2,8101824




















          1 Answer
          1






          active

          oldest

          votes


















          10














          STATISTICS IO does not include Version Store reads, at least for the version store in tempdb.



          Here's a demo for proof:



          --setup script
          USE master
          GO

          CREATE DATABASE TestDB
          GO

          ALTER DATABASE TestDB
          SET ALLOW_SNAPSHOT_ISOLATION ON
          GO

          USE TestDB
          GO

          DROP TABLE IF EXISTS dbo.Test
          GO

          CREATE TABLE dbo.Test (ID int identity PRIMARY KEY, junk int)

          INSERT dbo.Test
          SELECT TOP (100000) 1
          FROM master.dbo.spt_values a
          CROSS JOIN master.dbo.spt_values b


          Start a 30s update loop in one SSMS tab



          --UPDATE loop
          SET NOCOUNT ON
          DECLARE @stop datetime = DATEADD(SECOND, 30, GETDATE())

          WHILE GETDATE() < @stop
          BEGIN
          BEGIN TRAN

          UPDATE dbo.Test
          SET junk += 1

          COMMIT
          END

          UPDATE dbo.Test
          SET junk = 1


          And while the loop is going, run two identical queries in SNAPSHOT with STATISTICS IO ON, separated by 15s to allow versions to accumulate.



          USE TestDB
          SET STATISTICS IO ON
          GO

          SET TRANSACTION ISOLATION LEVEL SNAPSHOT

          BEGIN TRAN

          SELECT MAX(junk)
          FROM dbo.Test

          WAITFOR DELAY '00:00:15'

          SELECT MAX(junk)
          FROM dbo.Test

          COMMIT


          The IO stats show identical reads:
          Stats IO



          But the actual execution plan shows the scan for the second query taking far more time, due to reading the version store.
          Actual plans



          To prove to yourself that this query resulted in tempdb reads, you can use this Extended Events session (which is obviously better than Profiler), filtered to the session where the read queries are running:



          CREATE EVENT SESSION [file_reads] ON SERVER 
          ADD EVENT sqlserver.file_read_completed(
          ACTION(sqlserver.session_id,sqlserver.sql_text)
          WHERE ([sqlserver].[session_id]=(52)))
          ADD TARGET package0.event_file(SET filename=N'file_reads')
          GO


          Viewing the "live data" for that XE session during the demo, you can see reads against database id 2 (tempdb), and it captures the query text of our read query as well:



          screenshot of XE session showing tempdb reads



          Special thanks to Paul White for bringing up this issue with STATISTICS IO.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "182"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f237704%2fdoes-statistics-io-output-include-version-store-reads%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            10














            STATISTICS IO does not include Version Store reads, at least for the version store in tempdb.



            Here's a demo for proof:



            --setup script
            USE master
            GO

            CREATE DATABASE TestDB
            GO

            ALTER DATABASE TestDB
            SET ALLOW_SNAPSHOT_ISOLATION ON
            GO

            USE TestDB
            GO

            DROP TABLE IF EXISTS dbo.Test
            GO

            CREATE TABLE dbo.Test (ID int identity PRIMARY KEY, junk int)

            INSERT dbo.Test
            SELECT TOP (100000) 1
            FROM master.dbo.spt_values a
            CROSS JOIN master.dbo.spt_values b


            Start a 30s update loop in one SSMS tab



            --UPDATE loop
            SET NOCOUNT ON
            DECLARE @stop datetime = DATEADD(SECOND, 30, GETDATE())

            WHILE GETDATE() < @stop
            BEGIN
            BEGIN TRAN

            UPDATE dbo.Test
            SET junk += 1

            COMMIT
            END

            UPDATE dbo.Test
            SET junk = 1


            And while the loop is going, run two identical queries in SNAPSHOT with STATISTICS IO ON, separated by 15s to allow versions to accumulate.



            USE TestDB
            SET STATISTICS IO ON
            GO

            SET TRANSACTION ISOLATION LEVEL SNAPSHOT

            BEGIN TRAN

            SELECT MAX(junk)
            FROM dbo.Test

            WAITFOR DELAY '00:00:15'

            SELECT MAX(junk)
            FROM dbo.Test

            COMMIT


            The IO stats show identical reads:
            Stats IO



            But the actual execution plan shows the scan for the second query taking far more time, due to reading the version store.
            Actual plans



            To prove to yourself that this query resulted in tempdb reads, you can use this Extended Events session (which is obviously better than Profiler), filtered to the session where the read queries are running:



            CREATE EVENT SESSION [file_reads] ON SERVER 
            ADD EVENT sqlserver.file_read_completed(
            ACTION(sqlserver.session_id,sqlserver.sql_text)
            WHERE ([sqlserver].[session_id]=(52)))
            ADD TARGET package0.event_file(SET filename=N'file_reads')
            GO


            Viewing the "live data" for that XE session during the demo, you can see reads against database id 2 (tempdb), and it captures the query text of our read query as well:



            screenshot of XE session showing tempdb reads



            Special thanks to Paul White for bringing up this issue with STATISTICS IO.






            share|improve this answer





























              10














              STATISTICS IO does not include Version Store reads, at least for the version store in tempdb.



              Here's a demo for proof:



              --setup script
              USE master
              GO

              CREATE DATABASE TestDB
              GO

              ALTER DATABASE TestDB
              SET ALLOW_SNAPSHOT_ISOLATION ON
              GO

              USE TestDB
              GO

              DROP TABLE IF EXISTS dbo.Test
              GO

              CREATE TABLE dbo.Test (ID int identity PRIMARY KEY, junk int)

              INSERT dbo.Test
              SELECT TOP (100000) 1
              FROM master.dbo.spt_values a
              CROSS JOIN master.dbo.spt_values b


              Start a 30s update loop in one SSMS tab



              --UPDATE loop
              SET NOCOUNT ON
              DECLARE @stop datetime = DATEADD(SECOND, 30, GETDATE())

              WHILE GETDATE() < @stop
              BEGIN
              BEGIN TRAN

              UPDATE dbo.Test
              SET junk += 1

              COMMIT
              END

              UPDATE dbo.Test
              SET junk = 1


              And while the loop is going, run two identical queries in SNAPSHOT with STATISTICS IO ON, separated by 15s to allow versions to accumulate.



              USE TestDB
              SET STATISTICS IO ON
              GO

              SET TRANSACTION ISOLATION LEVEL SNAPSHOT

              BEGIN TRAN

              SELECT MAX(junk)
              FROM dbo.Test

              WAITFOR DELAY '00:00:15'

              SELECT MAX(junk)
              FROM dbo.Test

              COMMIT


              The IO stats show identical reads:
              Stats IO



              But the actual execution plan shows the scan for the second query taking far more time, due to reading the version store.
              Actual plans



              To prove to yourself that this query resulted in tempdb reads, you can use this Extended Events session (which is obviously better than Profiler), filtered to the session where the read queries are running:



              CREATE EVENT SESSION [file_reads] ON SERVER 
              ADD EVENT sqlserver.file_read_completed(
              ACTION(sqlserver.session_id,sqlserver.sql_text)
              WHERE ([sqlserver].[session_id]=(52)))
              ADD TARGET package0.event_file(SET filename=N'file_reads')
              GO


              Viewing the "live data" for that XE session during the demo, you can see reads against database id 2 (tempdb), and it captures the query text of our read query as well:



              screenshot of XE session showing tempdb reads



              Special thanks to Paul White for bringing up this issue with STATISTICS IO.






              share|improve this answer



























                10












                10








                10







                STATISTICS IO does not include Version Store reads, at least for the version store in tempdb.



                Here's a demo for proof:



                --setup script
                USE master
                GO

                CREATE DATABASE TestDB
                GO

                ALTER DATABASE TestDB
                SET ALLOW_SNAPSHOT_ISOLATION ON
                GO

                USE TestDB
                GO

                DROP TABLE IF EXISTS dbo.Test
                GO

                CREATE TABLE dbo.Test (ID int identity PRIMARY KEY, junk int)

                INSERT dbo.Test
                SELECT TOP (100000) 1
                FROM master.dbo.spt_values a
                CROSS JOIN master.dbo.spt_values b


                Start a 30s update loop in one SSMS tab



                --UPDATE loop
                SET NOCOUNT ON
                DECLARE @stop datetime = DATEADD(SECOND, 30, GETDATE())

                WHILE GETDATE() < @stop
                BEGIN
                BEGIN TRAN

                UPDATE dbo.Test
                SET junk += 1

                COMMIT
                END

                UPDATE dbo.Test
                SET junk = 1


                And while the loop is going, run two identical queries in SNAPSHOT with STATISTICS IO ON, separated by 15s to allow versions to accumulate.



                USE TestDB
                SET STATISTICS IO ON
                GO

                SET TRANSACTION ISOLATION LEVEL SNAPSHOT

                BEGIN TRAN

                SELECT MAX(junk)
                FROM dbo.Test

                WAITFOR DELAY '00:00:15'

                SELECT MAX(junk)
                FROM dbo.Test

                COMMIT


                The IO stats show identical reads:
                Stats IO



                But the actual execution plan shows the scan for the second query taking far more time, due to reading the version store.
                Actual plans



                To prove to yourself that this query resulted in tempdb reads, you can use this Extended Events session (which is obviously better than Profiler), filtered to the session where the read queries are running:



                CREATE EVENT SESSION [file_reads] ON SERVER 
                ADD EVENT sqlserver.file_read_completed(
                ACTION(sqlserver.session_id,sqlserver.sql_text)
                WHERE ([sqlserver].[session_id]=(52)))
                ADD TARGET package0.event_file(SET filename=N'file_reads')
                GO


                Viewing the "live data" for that XE session during the demo, you can see reads against database id 2 (tempdb), and it captures the query text of our read query as well:



                screenshot of XE session showing tempdb reads



                Special thanks to Paul White for bringing up this issue with STATISTICS IO.






                share|improve this answer















                STATISTICS IO does not include Version Store reads, at least for the version store in tempdb.



                Here's a demo for proof:



                --setup script
                USE master
                GO

                CREATE DATABASE TestDB
                GO

                ALTER DATABASE TestDB
                SET ALLOW_SNAPSHOT_ISOLATION ON
                GO

                USE TestDB
                GO

                DROP TABLE IF EXISTS dbo.Test
                GO

                CREATE TABLE dbo.Test (ID int identity PRIMARY KEY, junk int)

                INSERT dbo.Test
                SELECT TOP (100000) 1
                FROM master.dbo.spt_values a
                CROSS JOIN master.dbo.spt_values b


                Start a 30s update loop in one SSMS tab



                --UPDATE loop
                SET NOCOUNT ON
                DECLARE @stop datetime = DATEADD(SECOND, 30, GETDATE())

                WHILE GETDATE() < @stop
                BEGIN
                BEGIN TRAN

                UPDATE dbo.Test
                SET junk += 1

                COMMIT
                END

                UPDATE dbo.Test
                SET junk = 1


                And while the loop is going, run two identical queries in SNAPSHOT with STATISTICS IO ON, separated by 15s to allow versions to accumulate.



                USE TestDB
                SET STATISTICS IO ON
                GO

                SET TRANSACTION ISOLATION LEVEL SNAPSHOT

                BEGIN TRAN

                SELECT MAX(junk)
                FROM dbo.Test

                WAITFOR DELAY '00:00:15'

                SELECT MAX(junk)
                FROM dbo.Test

                COMMIT


                The IO stats show identical reads:
                Stats IO



                But the actual execution plan shows the scan for the second query taking far more time, due to reading the version store.
                Actual plans



                To prove to yourself that this query resulted in tempdb reads, you can use this Extended Events session (which is obviously better than Profiler), filtered to the session where the read queries are running:



                CREATE EVENT SESSION [file_reads] ON SERVER 
                ADD EVENT sqlserver.file_read_completed(
                ACTION(sqlserver.session_id,sqlserver.sql_text)
                WHERE ([sqlserver].[session_id]=(52)))
                ADD TARGET package0.event_file(SET filename=N'file_reads')
                GO


                Viewing the "live data" for that XE session during the demo, you can see reads against database id 2 (tempdb), and it captures the query text of our read query as well:



                screenshot of XE session showing tempdb reads



                Special thanks to Paul White for bringing up this issue with STATISTICS IO.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 9 at 13:58









                Josh Darnell

                9,09232345




                9,09232345










                answered May 9 at 2:50









                ForrestForrest

                2,8101824




                2,8101824



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f237704%2fdoes-statistics-io-output-include-version-store-reads%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                    What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                    Why did Thanos need his ship to help him in the battle scene?Which actor plays Thanos in the Avengers mid-credits scene?Are there economic implications portrayed in comics where the buildings and cities are ruined almost daily?Old X-Men comic where team travels to alien world with a ring-like sun that needs recharging?Why does Ego need help sleeping?Is there an objective answer to who “the strongest Avenger” is?How did Banner get unstuck?Why did Thanos get hit?How did Thanos (or anyone) know the Infinity Stones would give him this power?Did Thanos leave Eitri alive for his after-sales service?In Avengers 1, why does Thanos need Loki?