Indexed View vs. Table





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I had a long running query (relative to the data) that was hitting an indexed view. I thought an indexed view was physically stored data? I dumped everything into a table and ran the same query against the table and found that it executed almost 3x as fast. I was under the impression, which apparently was wrong, that an indexed view would act the same as a physical table in terms of performance. Just looking for an explanation.










share|improve this question




















  • 4





    What edition of SQL Server are you running under? Downlevel editions require the use of the NOEXPAND query hint in order to benefit most from the indexed view.

    – Damien_The_Unbeliever
    Nov 16 '18 at 18:57











  • Microsoft SQL Server Management Studio 13.0.16106.4

    – JMG
    Nov 16 '18 at 19:00






  • 2





    SQL Server Management Studio version doesn't usually matter. run select @@version on your system and see if it matches what you posted, which would be sql server 2016

    – scsimon
    Nov 16 '18 at 19:02











  • Microsoft SQL Server 2016 (SP1-GDR) (KB4057118) - 13.0.4210.6 (X64) Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3

    – JMG
    Nov 16 '18 at 19:06













  • Tested out WITH (NOEXPAND) - nailed it. Thanks guys!

    – JMG
    Nov 16 '18 at 19:13


















0















I had a long running query (relative to the data) that was hitting an indexed view. I thought an indexed view was physically stored data? I dumped everything into a table and ran the same query against the table and found that it executed almost 3x as fast. I was under the impression, which apparently was wrong, that an indexed view would act the same as a physical table in terms of performance. Just looking for an explanation.










share|improve this question




















  • 4





    What edition of SQL Server are you running under? Downlevel editions require the use of the NOEXPAND query hint in order to benefit most from the indexed view.

    – Damien_The_Unbeliever
    Nov 16 '18 at 18:57











  • Microsoft SQL Server Management Studio 13.0.16106.4

    – JMG
    Nov 16 '18 at 19:00






  • 2





    SQL Server Management Studio version doesn't usually matter. run select @@version on your system and see if it matches what you posted, which would be sql server 2016

    – scsimon
    Nov 16 '18 at 19:02











  • Microsoft SQL Server 2016 (SP1-GDR) (KB4057118) - 13.0.4210.6 (X64) Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3

    – JMG
    Nov 16 '18 at 19:06













  • Tested out WITH (NOEXPAND) - nailed it. Thanks guys!

    – JMG
    Nov 16 '18 at 19:13














0












0








0








I had a long running query (relative to the data) that was hitting an indexed view. I thought an indexed view was physically stored data? I dumped everything into a table and ran the same query against the table and found that it executed almost 3x as fast. I was under the impression, which apparently was wrong, that an indexed view would act the same as a physical table in terms of performance. Just looking for an explanation.










share|improve this question
















I had a long running query (relative to the data) that was hitting an indexed view. I thought an indexed view was physically stored data? I dumped everything into a table and ran the same query against the table and found that it executed almost 3x as fast. I was under the impression, which apparently was wrong, that an indexed view would act the same as a physical table in terms of performance. Just looking for an explanation.







sql sql-server performance sql-server-2016 indexed-view






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 19:01









scsimon

22.3k51737




22.3k51737










asked Nov 16 '18 at 18:55









JMGJMG

254




254








  • 4





    What edition of SQL Server are you running under? Downlevel editions require the use of the NOEXPAND query hint in order to benefit most from the indexed view.

    – Damien_The_Unbeliever
    Nov 16 '18 at 18:57











  • Microsoft SQL Server Management Studio 13.0.16106.4

    – JMG
    Nov 16 '18 at 19:00






  • 2





    SQL Server Management Studio version doesn't usually matter. run select @@version on your system and see if it matches what you posted, which would be sql server 2016

    – scsimon
    Nov 16 '18 at 19:02











  • Microsoft SQL Server 2016 (SP1-GDR) (KB4057118) - 13.0.4210.6 (X64) Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3

    – JMG
    Nov 16 '18 at 19:06













  • Tested out WITH (NOEXPAND) - nailed it. Thanks guys!

    – JMG
    Nov 16 '18 at 19:13














  • 4





    What edition of SQL Server are you running under? Downlevel editions require the use of the NOEXPAND query hint in order to benefit most from the indexed view.

    – Damien_The_Unbeliever
    Nov 16 '18 at 18:57











  • Microsoft SQL Server Management Studio 13.0.16106.4

    – JMG
    Nov 16 '18 at 19:00






  • 2





    SQL Server Management Studio version doesn't usually matter. run select @@version on your system and see if it matches what you posted, which would be sql server 2016

    – scsimon
    Nov 16 '18 at 19:02











  • Microsoft SQL Server 2016 (SP1-GDR) (KB4057118) - 13.0.4210.6 (X64) Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3

    – JMG
    Nov 16 '18 at 19:06













  • Tested out WITH (NOEXPAND) - nailed it. Thanks guys!

    – JMG
    Nov 16 '18 at 19:13








4




4





What edition of SQL Server are you running under? Downlevel editions require the use of the NOEXPAND query hint in order to benefit most from the indexed view.

– Damien_The_Unbeliever
Nov 16 '18 at 18:57





What edition of SQL Server are you running under? Downlevel editions require the use of the NOEXPAND query hint in order to benefit most from the indexed view.

– Damien_The_Unbeliever
Nov 16 '18 at 18:57













Microsoft SQL Server Management Studio 13.0.16106.4

– JMG
Nov 16 '18 at 19:00





Microsoft SQL Server Management Studio 13.0.16106.4

– JMG
Nov 16 '18 at 19:00




2




2





SQL Server Management Studio version doesn't usually matter. run select @@version on your system and see if it matches what you posted, which would be sql server 2016

– scsimon
Nov 16 '18 at 19:02





SQL Server Management Studio version doesn't usually matter. run select @@version on your system and see if it matches what you posted, which would be sql server 2016

– scsimon
Nov 16 '18 at 19:02













Microsoft SQL Server 2016 (SP1-GDR) (KB4057118) - 13.0.4210.6 (X64) Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3

– JMG
Nov 16 '18 at 19:06







Microsoft SQL Server 2016 (SP1-GDR) (KB4057118) - 13.0.4210.6 (X64) Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3

– JMG
Nov 16 '18 at 19:06















Tested out WITH (NOEXPAND) - nailed it. Thanks guys!

– JMG
Nov 16 '18 at 19:13





Tested out WITH (NOEXPAND) - nailed it. Thanks guys!

– JMG
Nov 16 '18 at 19:13












1 Answer
1






active

oldest

votes


















0















What edition of SQL Server are you running under? Downlevel editions
require the use of the NOEXPAND query hint in order to benefit most
from the indexed view. – Damien_The_Unbeliever




This was the answer, thanks again






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f53343822%2findexed-view-vs-table%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









    0















    What edition of SQL Server are you running under? Downlevel editions
    require the use of the NOEXPAND query hint in order to benefit most
    from the indexed view. – Damien_The_Unbeliever




    This was the answer, thanks again






    share|improve this answer




























      0















      What edition of SQL Server are you running under? Downlevel editions
      require the use of the NOEXPAND query hint in order to benefit most
      from the indexed view. – Damien_The_Unbeliever




      This was the answer, thanks again






      share|improve this answer


























        0












        0








        0








        What edition of SQL Server are you running under? Downlevel editions
        require the use of the NOEXPAND query hint in order to benefit most
        from the indexed view. – Damien_The_Unbeliever




        This was the answer, thanks again






        share|improve this answer














        What edition of SQL Server are you running under? Downlevel editions
        require the use of the NOEXPAND query hint in order to benefit most
        from the indexed view. – Damien_The_Unbeliever




        This was the answer, thanks again







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 21:21









        JMGJMG

        254




        254
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f53343822%2findexed-view-vs-table%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

            Florida Star v. B. J. F.

            Error while running script in elastic search , gateway timeout

            Adding quotations to stringified JSON object values