MAXDOP = 1, Query Hints and Cost Threshold For Parallelism

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





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







up vote
9
down vote

favorite












If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?



I haven’t been able to dig up this specific information although this link suggests that CTFP is ignored if MAXDOP is 1. This makes sense without query hints as no request, regardless of cost, will go parallel when MAXDOP is 1.



Can anyone let me know what the expected behaviour of these two requests will be?



Example 1:



Instance Maxdop: 1 
CTFP: 50
Query hint: Maxdop=2
Query cost: 30


Example 2:



Instance Maxdop: 1
CTFP: 50
Query hint: Maxdop=2
Query cost: 70






share|improve this question




























    up vote
    9
    down vote

    favorite












    If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?



    I haven’t been able to dig up this specific information although this link suggests that CTFP is ignored if MAXDOP is 1. This makes sense without query hints as no request, regardless of cost, will go parallel when MAXDOP is 1.



    Can anyone let me know what the expected behaviour of these two requests will be?



    Example 1:



    Instance Maxdop: 1 
    CTFP: 50
    Query hint: Maxdop=2
    Query cost: 30


    Example 2:



    Instance Maxdop: 1
    CTFP: 50
    Query hint: Maxdop=2
    Query cost: 70






    share|improve this question
























      up vote
      9
      down vote

      favorite









      up vote
      9
      down vote

      favorite











      If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?



      I haven’t been able to dig up this specific information although this link suggests that CTFP is ignored if MAXDOP is 1. This makes sense without query hints as no request, regardless of cost, will go parallel when MAXDOP is 1.



      Can anyone let me know what the expected behaviour of these two requests will be?



      Example 1:



      Instance Maxdop: 1 
      CTFP: 50
      Query hint: Maxdop=2
      Query cost: 30


      Example 2:



      Instance Maxdop: 1
      CTFP: 50
      Query hint: Maxdop=2
      Query cost: 70






      share|improve this question














      If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?



      I haven’t been able to dig up this specific information although this link suggests that CTFP is ignored if MAXDOP is 1. This makes sense without query hints as no request, regardless of cost, will go parallel when MAXDOP is 1.



      Can anyone let me know what the expected behaviour of these two requests will be?



      Example 1:



      Instance Maxdop: 1 
      CTFP: 50
      Query hint: Maxdop=2
      Query cost: 30


      Example 2:



      Instance Maxdop: 1
      CTFP: 50
      Query hint: Maxdop=2
      Query cost: 70








      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 22 at 9:15









      Paul White♦

      46.1k14247395




      46.1k14247395










      asked Aug 22 at 5:54









      Martin Bansey

      484




      484




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          16
          down vote



          accepted











          If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




          Simple answer: yes.



          Details



          There are a couple of separate things going on here, which it is important to separate:




          1. What is the effective maximum degree of parallelism available to a query?



            The contributors to this are (broadly in order of importance):



            • Resource Governor MAX_DOP setting

            • Query hint MAXDOP setting

            • The max degree of parallelism instance configuration option

            The details are explained in Server’s “Max Degree of Parallelism” setting, Resource Governor’s MAX_DOP and query hint MAXDOP–which one should SQL Server use? by Jack Li, Senior Escalation Engineer for Microsoft SQL Server Customer Service and Support. The table below is reproduced from that link:




            parallelism table





          2. Will a query plan use parallelism?



            The SQL Server query optimizer always finds a serial plan first.



            Then, if:



            • Further optimization is justified; and

            • The cost of the best serial plan exceeds the cost threshold for parallelism configuration value



            ...the optimizer will try to find a parallel plan.



            Then, if:



            • A parallel plan is found (i.e. is possible); and

            • The cost of the parallel plan is less than the best serial plan



            ...a parallel plan will be produced.



          Note: the cost threshold for parallelism only affects whether the optimizer looks for a parallel plan. Once a parallel plan is cached, it will execute using parallelism when it is reused (so long as threads are available) regardless of the CTFP setting.




          Examples



          For both examples, with instance maxdop 1 and query hint maxdop 2, the effective available DOP is 2. If a parallel plan is chosen, it will use DOP 2.



          Example 1



          Given CTFP of 50 and a cheapest serial plan found cost of 30, SQL Server will not try to find a parallel plan. A serial plan will be produced.



          Example 2



          Given CTFP of 50 and a cheapest serial plan found cost of 70, SQL Server will try to find a parallel plan. If this plan (if found) has a cost less than 70 (the serial plan cost) then a parallel plan will be produced.






          share|improve this answer






















          • Thanks for adding the link from blogs.msdn, that is helpful. What do you mean "try to find a parallel plan". AFAIK barring certain cases optimizer would mostly produce many plans which would include both serial and parallel and depending on cost and configuration may choose best plan. So I believe there is always a parallel plan and it does not need to be found.
            – Shanky
            Aug 22 at 9:25







          • 1




            The end result of query optimization is always a single cached plan: serial or parallel. The optimizer finds only a serial plan in search0 (TP) and search1 (QP) phases. It may then (as described) re-run search1 with a requirement to produce a parallel plan. A choice is then made between serial and parallel based on best whole plan cost so far. That choice is binding in case optimization moves on to search2 (Full Optimization). Yes, each phase of optimization considers many alternatives, but the output from a stage is always a single best plan, which is either serial or parallel.
            – Paul White♦
            Aug 22 at 9:35






          • 4




            I wrote about some of this in Myth: SQL Server Caches a Serial Plan with every Parallel Plan
            – Paul White♦
            Aug 22 at 9:38










          • Not applicable to the version stated in the question, but perhaps a note about database MAXDOP is worth mentioning? I can't find a good place to edit it in.
            – Joe Obbish
            Aug 22 at 22:51

















          up vote
          2
          down vote














          Example 1 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 30




          The MAXDOP query hint overrides the max degree of parallelism setting instance wide but since CTPF is 50 and query cost is 30 it may go for serial plan.




          Example 2 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 70




          Here again max degree of parallelism will be taken as 2 since MAXDOP hint is there but CTFP will be taken as 50 and query, if possible like Paul mentioned may run in parallel.




          If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




          MAXDOP hint will override the instance wide setting of max degree of parallelism.



          Quoting from MAXDOP hint docs.microsoft




          MAXDOP number Applies to: SQL Server 2008 through SQL Server 2017.



          Overrides the max degree of parallelism configuration option of
          sp_configure and Resource Governor for the query specifying this
          option. The MAXDOP query hint can exceed the value configured with
          sp_configure. If MAXDOP exceeds the value configured with Resource
          Governor, the Database Engine uses the Resource Governor MAXDOP value,







          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f215548%2fmaxdop-1-query-hints-and-cost-threshold-for-parallelism%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            16
            down vote



            accepted











            If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




            Simple answer: yes.



            Details



            There are a couple of separate things going on here, which it is important to separate:




            1. What is the effective maximum degree of parallelism available to a query?



              The contributors to this are (broadly in order of importance):



              • Resource Governor MAX_DOP setting

              • Query hint MAXDOP setting

              • The max degree of parallelism instance configuration option

              The details are explained in Server’s “Max Degree of Parallelism” setting, Resource Governor’s MAX_DOP and query hint MAXDOP–which one should SQL Server use? by Jack Li, Senior Escalation Engineer for Microsoft SQL Server Customer Service and Support. The table below is reproduced from that link:




              parallelism table





            2. Will a query plan use parallelism?



              The SQL Server query optimizer always finds a serial plan first.



              Then, if:



              • Further optimization is justified; and

              • The cost of the best serial plan exceeds the cost threshold for parallelism configuration value



              ...the optimizer will try to find a parallel plan.



              Then, if:



              • A parallel plan is found (i.e. is possible); and

              • The cost of the parallel plan is less than the best serial plan



              ...a parallel plan will be produced.



            Note: the cost threshold for parallelism only affects whether the optimizer looks for a parallel plan. Once a parallel plan is cached, it will execute using parallelism when it is reused (so long as threads are available) regardless of the CTFP setting.




            Examples



            For both examples, with instance maxdop 1 and query hint maxdop 2, the effective available DOP is 2. If a parallel plan is chosen, it will use DOP 2.



            Example 1



            Given CTFP of 50 and a cheapest serial plan found cost of 30, SQL Server will not try to find a parallel plan. A serial plan will be produced.



            Example 2



            Given CTFP of 50 and a cheapest serial plan found cost of 70, SQL Server will try to find a parallel plan. If this plan (if found) has a cost less than 70 (the serial plan cost) then a parallel plan will be produced.






            share|improve this answer






















            • Thanks for adding the link from blogs.msdn, that is helpful. What do you mean "try to find a parallel plan". AFAIK barring certain cases optimizer would mostly produce many plans which would include both serial and parallel and depending on cost and configuration may choose best plan. So I believe there is always a parallel plan and it does not need to be found.
              – Shanky
              Aug 22 at 9:25







            • 1




              The end result of query optimization is always a single cached plan: serial or parallel. The optimizer finds only a serial plan in search0 (TP) and search1 (QP) phases. It may then (as described) re-run search1 with a requirement to produce a parallel plan. A choice is then made between serial and parallel based on best whole plan cost so far. That choice is binding in case optimization moves on to search2 (Full Optimization). Yes, each phase of optimization considers many alternatives, but the output from a stage is always a single best plan, which is either serial or parallel.
              – Paul White♦
              Aug 22 at 9:35






            • 4




              I wrote about some of this in Myth: SQL Server Caches a Serial Plan with every Parallel Plan
              – Paul White♦
              Aug 22 at 9:38










            • Not applicable to the version stated in the question, but perhaps a note about database MAXDOP is worth mentioning? I can't find a good place to edit it in.
              – Joe Obbish
              Aug 22 at 22:51














            up vote
            16
            down vote



            accepted











            If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




            Simple answer: yes.



            Details



            There are a couple of separate things going on here, which it is important to separate:




            1. What is the effective maximum degree of parallelism available to a query?



              The contributors to this are (broadly in order of importance):



              • Resource Governor MAX_DOP setting

              • Query hint MAXDOP setting

              • The max degree of parallelism instance configuration option

              The details are explained in Server’s “Max Degree of Parallelism” setting, Resource Governor’s MAX_DOP and query hint MAXDOP–which one should SQL Server use? by Jack Li, Senior Escalation Engineer for Microsoft SQL Server Customer Service and Support. The table below is reproduced from that link:




              parallelism table





            2. Will a query plan use parallelism?



              The SQL Server query optimizer always finds a serial plan first.



              Then, if:



              • Further optimization is justified; and

              • The cost of the best serial plan exceeds the cost threshold for parallelism configuration value



              ...the optimizer will try to find a parallel plan.



              Then, if:



              • A parallel plan is found (i.e. is possible); and

              • The cost of the parallel plan is less than the best serial plan



              ...a parallel plan will be produced.



            Note: the cost threshold for parallelism only affects whether the optimizer looks for a parallel plan. Once a parallel plan is cached, it will execute using parallelism when it is reused (so long as threads are available) regardless of the CTFP setting.




            Examples



            For both examples, with instance maxdop 1 and query hint maxdop 2, the effective available DOP is 2. If a parallel plan is chosen, it will use DOP 2.



            Example 1



            Given CTFP of 50 and a cheapest serial plan found cost of 30, SQL Server will not try to find a parallel plan. A serial plan will be produced.



            Example 2



            Given CTFP of 50 and a cheapest serial plan found cost of 70, SQL Server will try to find a parallel plan. If this plan (if found) has a cost less than 70 (the serial plan cost) then a parallel plan will be produced.






            share|improve this answer






















            • Thanks for adding the link from blogs.msdn, that is helpful. What do you mean "try to find a parallel plan". AFAIK barring certain cases optimizer would mostly produce many plans which would include both serial and parallel and depending on cost and configuration may choose best plan. So I believe there is always a parallel plan and it does not need to be found.
              – Shanky
              Aug 22 at 9:25







            • 1




              The end result of query optimization is always a single cached plan: serial or parallel. The optimizer finds only a serial plan in search0 (TP) and search1 (QP) phases. It may then (as described) re-run search1 with a requirement to produce a parallel plan. A choice is then made between serial and parallel based on best whole plan cost so far. That choice is binding in case optimization moves on to search2 (Full Optimization). Yes, each phase of optimization considers many alternatives, but the output from a stage is always a single best plan, which is either serial or parallel.
              – Paul White♦
              Aug 22 at 9:35






            • 4




              I wrote about some of this in Myth: SQL Server Caches a Serial Plan with every Parallel Plan
              – Paul White♦
              Aug 22 at 9:38










            • Not applicable to the version stated in the question, but perhaps a note about database MAXDOP is worth mentioning? I can't find a good place to edit it in.
              – Joe Obbish
              Aug 22 at 22:51












            up vote
            16
            down vote



            accepted







            up vote
            16
            down vote



            accepted







            If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




            Simple answer: yes.



            Details



            There are a couple of separate things going on here, which it is important to separate:




            1. What is the effective maximum degree of parallelism available to a query?



              The contributors to this are (broadly in order of importance):



              • Resource Governor MAX_DOP setting

              • Query hint MAXDOP setting

              • The max degree of parallelism instance configuration option

              The details are explained in Server’s “Max Degree of Parallelism” setting, Resource Governor’s MAX_DOP and query hint MAXDOP–which one should SQL Server use? by Jack Li, Senior Escalation Engineer for Microsoft SQL Server Customer Service and Support. The table below is reproduced from that link:




              parallelism table





            2. Will a query plan use parallelism?



              The SQL Server query optimizer always finds a serial plan first.



              Then, if:



              • Further optimization is justified; and

              • The cost of the best serial plan exceeds the cost threshold for parallelism configuration value



              ...the optimizer will try to find a parallel plan.



              Then, if:



              • A parallel plan is found (i.e. is possible); and

              • The cost of the parallel plan is less than the best serial plan



              ...a parallel plan will be produced.



            Note: the cost threshold for parallelism only affects whether the optimizer looks for a parallel plan. Once a parallel plan is cached, it will execute using parallelism when it is reused (so long as threads are available) regardless of the CTFP setting.




            Examples



            For both examples, with instance maxdop 1 and query hint maxdop 2, the effective available DOP is 2. If a parallel plan is chosen, it will use DOP 2.



            Example 1



            Given CTFP of 50 and a cheapest serial plan found cost of 30, SQL Server will not try to find a parallel plan. A serial plan will be produced.



            Example 2



            Given CTFP of 50 and a cheapest serial plan found cost of 70, SQL Server will try to find a parallel plan. If this plan (if found) has a cost less than 70 (the serial plan cost) then a parallel plan will be produced.






            share|improve this answer















            If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




            Simple answer: yes.



            Details



            There are a couple of separate things going on here, which it is important to separate:




            1. What is the effective maximum degree of parallelism available to a query?



              The contributors to this are (broadly in order of importance):



              • Resource Governor MAX_DOP setting

              • Query hint MAXDOP setting

              • The max degree of parallelism instance configuration option

              The details are explained in Server’s “Max Degree of Parallelism” setting, Resource Governor’s MAX_DOP and query hint MAXDOP–which one should SQL Server use? by Jack Li, Senior Escalation Engineer for Microsoft SQL Server Customer Service and Support. The table below is reproduced from that link:




              parallelism table





            2. Will a query plan use parallelism?



              The SQL Server query optimizer always finds a serial plan first.



              Then, if:



              • Further optimization is justified; and

              • The cost of the best serial plan exceeds the cost threshold for parallelism configuration value



              ...the optimizer will try to find a parallel plan.



              Then, if:



              • A parallel plan is found (i.e. is possible); and

              • The cost of the parallel plan is less than the best serial plan



              ...a parallel plan will be produced.



            Note: the cost threshold for parallelism only affects whether the optimizer looks for a parallel plan. Once a parallel plan is cached, it will execute using parallelism when it is reused (so long as threads are available) regardless of the CTFP setting.




            Examples



            For both examples, with instance maxdop 1 and query hint maxdop 2, the effective available DOP is 2. If a parallel plan is chosen, it will use DOP 2.



            Example 1



            Given CTFP of 50 and a cheapest serial plan found cost of 30, SQL Server will not try to find a parallel plan. A serial plan will be produced.



            Example 2



            Given CTFP of 50 and a cheapest serial plan found cost of 70, SQL Server will try to find a parallel plan. If this plan (if found) has a cost less than 70 (the serial plan cost) then a parallel plan will be produced.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 22 at 9:22

























            answered Aug 22 at 9:13









            Paul White♦

            46.1k14247395




            46.1k14247395











            • Thanks for adding the link from blogs.msdn, that is helpful. What do you mean "try to find a parallel plan". AFAIK barring certain cases optimizer would mostly produce many plans which would include both serial and parallel and depending on cost and configuration may choose best plan. So I believe there is always a parallel plan and it does not need to be found.
              – Shanky
              Aug 22 at 9:25







            • 1




              The end result of query optimization is always a single cached plan: serial or parallel. The optimizer finds only a serial plan in search0 (TP) and search1 (QP) phases. It may then (as described) re-run search1 with a requirement to produce a parallel plan. A choice is then made between serial and parallel based on best whole plan cost so far. That choice is binding in case optimization moves on to search2 (Full Optimization). Yes, each phase of optimization considers many alternatives, but the output from a stage is always a single best plan, which is either serial or parallel.
              – Paul White♦
              Aug 22 at 9:35






            • 4




              I wrote about some of this in Myth: SQL Server Caches a Serial Plan with every Parallel Plan
              – Paul White♦
              Aug 22 at 9:38










            • Not applicable to the version stated in the question, but perhaps a note about database MAXDOP is worth mentioning? I can't find a good place to edit it in.
              – Joe Obbish
              Aug 22 at 22:51
















            • Thanks for adding the link from blogs.msdn, that is helpful. What do you mean "try to find a parallel plan". AFAIK barring certain cases optimizer would mostly produce many plans which would include both serial and parallel and depending on cost and configuration may choose best plan. So I believe there is always a parallel plan and it does not need to be found.
              – Shanky
              Aug 22 at 9:25







            • 1




              The end result of query optimization is always a single cached plan: serial or parallel. The optimizer finds only a serial plan in search0 (TP) and search1 (QP) phases. It may then (as described) re-run search1 with a requirement to produce a parallel plan. A choice is then made between serial and parallel based on best whole plan cost so far. That choice is binding in case optimization moves on to search2 (Full Optimization). Yes, each phase of optimization considers many alternatives, but the output from a stage is always a single best plan, which is either serial or parallel.
              – Paul White♦
              Aug 22 at 9:35






            • 4




              I wrote about some of this in Myth: SQL Server Caches a Serial Plan with every Parallel Plan
              – Paul White♦
              Aug 22 at 9:38










            • Not applicable to the version stated in the question, but perhaps a note about database MAXDOP is worth mentioning? I can't find a good place to edit it in.
              – Joe Obbish
              Aug 22 at 22:51















            Thanks for adding the link from blogs.msdn, that is helpful. What do you mean "try to find a parallel plan". AFAIK barring certain cases optimizer would mostly produce many plans which would include both serial and parallel and depending on cost and configuration may choose best plan. So I believe there is always a parallel plan and it does not need to be found.
            – Shanky
            Aug 22 at 9:25





            Thanks for adding the link from blogs.msdn, that is helpful. What do you mean "try to find a parallel plan". AFAIK barring certain cases optimizer would mostly produce many plans which would include both serial and parallel and depending on cost and configuration may choose best plan. So I believe there is always a parallel plan and it does not need to be found.
            – Shanky
            Aug 22 at 9:25





            1




            1




            The end result of query optimization is always a single cached plan: serial or parallel. The optimizer finds only a serial plan in search0 (TP) and search1 (QP) phases. It may then (as described) re-run search1 with a requirement to produce a parallel plan. A choice is then made between serial and parallel based on best whole plan cost so far. That choice is binding in case optimization moves on to search2 (Full Optimization). Yes, each phase of optimization considers many alternatives, but the output from a stage is always a single best plan, which is either serial or parallel.
            – Paul White♦
            Aug 22 at 9:35




            The end result of query optimization is always a single cached plan: serial or parallel. The optimizer finds only a serial plan in search0 (TP) and search1 (QP) phases. It may then (as described) re-run search1 with a requirement to produce a parallel plan. A choice is then made between serial and parallel based on best whole plan cost so far. That choice is binding in case optimization moves on to search2 (Full Optimization). Yes, each phase of optimization considers many alternatives, but the output from a stage is always a single best plan, which is either serial or parallel.
            – Paul White♦
            Aug 22 at 9:35




            4




            4




            I wrote about some of this in Myth: SQL Server Caches a Serial Plan with every Parallel Plan
            – Paul White♦
            Aug 22 at 9:38




            I wrote about some of this in Myth: SQL Server Caches a Serial Plan with every Parallel Plan
            – Paul White♦
            Aug 22 at 9:38












            Not applicable to the version stated in the question, but perhaps a note about database MAXDOP is worth mentioning? I can't find a good place to edit it in.
            – Joe Obbish
            Aug 22 at 22:51




            Not applicable to the version stated in the question, but perhaps a note about database MAXDOP is worth mentioning? I can't find a good place to edit it in.
            – Joe Obbish
            Aug 22 at 22:51












            up vote
            2
            down vote














            Example 1 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 30




            The MAXDOP query hint overrides the max degree of parallelism setting instance wide but since CTPF is 50 and query cost is 30 it may go for serial plan.




            Example 2 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 70




            Here again max degree of parallelism will be taken as 2 since MAXDOP hint is there but CTFP will be taken as 50 and query, if possible like Paul mentioned may run in parallel.




            If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




            MAXDOP hint will override the instance wide setting of max degree of parallelism.



            Quoting from MAXDOP hint docs.microsoft




            MAXDOP number Applies to: SQL Server 2008 through SQL Server 2017.



            Overrides the max degree of parallelism configuration option of
            sp_configure and Resource Governor for the query specifying this
            option. The MAXDOP query hint can exceed the value configured with
            sp_configure. If MAXDOP exceeds the value configured with Resource
            Governor, the Database Engine uses the Resource Governor MAXDOP value,







            share|improve this answer


























              up vote
              2
              down vote














              Example 1 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 30




              The MAXDOP query hint overrides the max degree of parallelism setting instance wide but since CTPF is 50 and query cost is 30 it may go for serial plan.




              Example 2 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 70




              Here again max degree of parallelism will be taken as 2 since MAXDOP hint is there but CTFP will be taken as 50 and query, if possible like Paul mentioned may run in parallel.




              If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




              MAXDOP hint will override the instance wide setting of max degree of parallelism.



              Quoting from MAXDOP hint docs.microsoft




              MAXDOP number Applies to: SQL Server 2008 through SQL Server 2017.



              Overrides the max degree of parallelism configuration option of
              sp_configure and Resource Governor for the query specifying this
              option. The MAXDOP query hint can exceed the value configured with
              sp_configure. If MAXDOP exceeds the value configured with Resource
              Governor, the Database Engine uses the Resource Governor MAXDOP value,







              share|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote










                Example 1 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 30




                The MAXDOP query hint overrides the max degree of parallelism setting instance wide but since CTPF is 50 and query cost is 30 it may go for serial plan.




                Example 2 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 70




                Here again max degree of parallelism will be taken as 2 since MAXDOP hint is there but CTFP will be taken as 50 and query, if possible like Paul mentioned may run in parallel.




                If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




                MAXDOP hint will override the instance wide setting of max degree of parallelism.



                Quoting from MAXDOP hint docs.microsoft




                MAXDOP number Applies to: SQL Server 2008 through SQL Server 2017.



                Overrides the max degree of parallelism configuration option of
                sp_configure and Resource Governor for the query specifying this
                option. The MAXDOP query hint can exceed the value configured with
                sp_configure. If MAXDOP exceeds the value configured with Resource
                Governor, the Database Engine uses the Resource Governor MAXDOP value,







                share|improve this answer















                Example 1 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 30




                The MAXDOP query hint overrides the max degree of parallelism setting instance wide but since CTPF is 50 and query cost is 30 it may go for serial plan.




                Example 2 Instance Maxdop: 1 CTFP: 50 Query hint: Maxdop=2 Query cost: 70




                Here again max degree of parallelism will be taken as 2 since MAXDOP hint is there but CTFP will be taken as 50 and query, if possible like Paul mentioned may run in parallel.




                If an instance has MAXDOP set at 1 and query hints are used to allow specific queries to go parallel, is the Cost Threshold For Parallelism value still used by SQL to decide whether or not to actually go parallel?




                MAXDOP hint will override the instance wide setting of max degree of parallelism.



                Quoting from MAXDOP hint docs.microsoft




                MAXDOP number Applies to: SQL Server 2008 through SQL Server 2017.



                Overrides the max degree of parallelism configuration option of
                sp_configure and Resource Governor for the query specifying this
                option. The MAXDOP query hint can exceed the value configured with
                sp_configure. If MAXDOP exceeds the value configured with Resource
                Governor, the Database Engine uses the Resource Governor MAXDOP value,








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 22 at 9:20

























                answered Aug 22 at 7:37









                Shanky

                13.1k31939




                13.1k31939






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f215548%2fmaxdop-1-query-hints-and-cost-threshold-for-parallelism%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    這個網誌中的熱門文章

                    How to combine Bézier curves to a surface?

                    Mutual Information Always Non-negative

                    Why am i infinitely getting the same tweet with the Twitter Search API?