sp_blitzCache against one stored procedureCode creates different plan when ran ad-hoc vs. in a stored procedureCan I get SSMS to show me the Actual query costs in the Execution plan pane?Procedure cache (plan cache) sizeSQL Server 2012 Resource Governor and memory used by CLRUnderstanding below execution planQueries running slower on production (failover cluster) than on homologation envcomparing left join and outer apply doing the same thingQuery memory grant and tempdb spillInclude stored procedure text output in the maintenance plan logHash join spills to disk even though there is plenty of memory granted for the query

Devil Fruit Question

Is it allowed to activate the ability of multiple planeswalkers in a single turn?

Mysterious "Two documentclass or documentstyle commands."

How does electrical safety system work on ISS?

What is the English pronunciation of "pain au chocolat"?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

What (the heck) is a Super Worm Equinox Moon?

Why is the Sun approximated as a black body at ~ 5800 K?

Quoting Keynes in a lecture

Make a Bowl of Alphabet Soup

What kind of floor tile is this?

Are cause and effect the same as in our Universe in a non-relativistic, Newtonian Universe in which the speed of light is infinite?

When were female captains banned from Starfleet?

Why the "ls" command is showing the permissions of files in a FAT32 partition?

Review your own paper in Mathematics

Can I say "fingers" when referring to toes?

15% tax on $7.5k earnings. Is that right?

Is there a nicer/politer/more positive alternative for "negates"?

Isometries between spherical space forms

Microchip documentation does not label CAN buss pins on micro controller pinout diagram

Temporarily disable WLAN internet access for children, but allow it for adults

JIS and ISO square taper

How can ping know if my host is down

Is this toilet slogan correct usage of the English language?



sp_blitzCache against one stored procedure


Code creates different plan when ran ad-hoc vs. in a stored procedureCan I get SSMS to show me the Actual query costs in the Execution plan pane?Procedure cache (plan cache) sizeSQL Server 2012 Resource Governor and memory used by CLRUnderstanding below execution planQueries running slower on production (failover cluster) than on homologation envcomparing left join and outer apply doing the same thingQuery memory grant and tempdb spillInclude stored procedure text output in the maintenance plan logHash join spills to disk even though there is plenty of memory granted for the query













2















Recently we started using sp_BlitzCache to help us tune our queries. We found one SP that had some issues with it and we were able to refactor it successfully.



I have a copy of the output of sp_BlitzCache taken during the week before we tuned the query, it is available here



https://drive.google.com/open?id=1oiAEl62ZT51qcCEhVzkg8oDA3HB-NCsv



The command run to generate this output was



exec sp_BlitzCache @StoredProcName = 'hs_UpdateShipmentPackagesAndWeightSp'


Few questions



1) I noticed that we have multiple rows for the same plan handle, why is that?



2) You'll notice that the highest cost query (1451) has a query text of the entire create procedure statement, what does that mean? Are the metrics for this row just for the creation of the stored procedure?



3) For the highest cost row, the one referenced above, it has a Min/Max grant of almost 2GB. Does that mean that when we run the create procedure statement it asked for 2gb of memory? Or is this plan being used when the proc is called ? I suppose this ties into the answer from question 2



4) Why in some cases we have Min/Max grant KB > 0 and Min/Max used grant kb > 0, but percent memory grant used is null ?



We are running SQL Server 2012.



Thanks,
Kevin










share|improve this question









New contributor




kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    2















    Recently we started using sp_BlitzCache to help us tune our queries. We found one SP that had some issues with it and we were able to refactor it successfully.



    I have a copy of the output of sp_BlitzCache taken during the week before we tuned the query, it is available here



    https://drive.google.com/open?id=1oiAEl62ZT51qcCEhVzkg8oDA3HB-NCsv



    The command run to generate this output was



    exec sp_BlitzCache @StoredProcName = 'hs_UpdateShipmentPackagesAndWeightSp'


    Few questions



    1) I noticed that we have multiple rows for the same plan handle, why is that?



    2) You'll notice that the highest cost query (1451) has a query text of the entire create procedure statement, what does that mean? Are the metrics for this row just for the creation of the stored procedure?



    3) For the highest cost row, the one referenced above, it has a Min/Max grant of almost 2GB. Does that mean that when we run the create procedure statement it asked for 2gb of memory? Or is this plan being used when the proc is called ? I suppose this ties into the answer from question 2



    4) Why in some cases we have Min/Max grant KB > 0 and Min/Max used grant kb > 0, but percent memory grant used is null ?



    We are running SQL Server 2012.



    Thanks,
    Kevin










    share|improve this question









    New contributor




    kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      2












      2








      2








      Recently we started using sp_BlitzCache to help us tune our queries. We found one SP that had some issues with it and we were able to refactor it successfully.



      I have a copy of the output of sp_BlitzCache taken during the week before we tuned the query, it is available here



      https://drive.google.com/open?id=1oiAEl62ZT51qcCEhVzkg8oDA3HB-NCsv



      The command run to generate this output was



      exec sp_BlitzCache @StoredProcName = 'hs_UpdateShipmentPackagesAndWeightSp'


      Few questions



      1) I noticed that we have multiple rows for the same plan handle, why is that?



      2) You'll notice that the highest cost query (1451) has a query text of the entire create procedure statement, what does that mean? Are the metrics for this row just for the creation of the stored procedure?



      3) For the highest cost row, the one referenced above, it has a Min/Max grant of almost 2GB. Does that mean that when we run the create procedure statement it asked for 2gb of memory? Or is this plan being used when the proc is called ? I suppose this ties into the answer from question 2



      4) Why in some cases we have Min/Max grant KB > 0 and Min/Max used grant kb > 0, but percent memory grant used is null ?



      We are running SQL Server 2012.



      Thanks,
      Kevin










      share|improve this question









      New contributor




      kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Recently we started using sp_BlitzCache to help us tune our queries. We found one SP that had some issues with it and we were able to refactor it successfully.



      I have a copy of the output of sp_BlitzCache taken during the week before we tuned the query, it is available here



      https://drive.google.com/open?id=1oiAEl62ZT51qcCEhVzkg8oDA3HB-NCsv



      The command run to generate this output was



      exec sp_BlitzCache @StoredProcName = 'hs_UpdateShipmentPackagesAndWeightSp'


      Few questions



      1) I noticed that we have multiple rows for the same plan handle, why is that?



      2) You'll notice that the highest cost query (1451) has a query text of the entire create procedure statement, what does that mean? Are the metrics for this row just for the creation of the stored procedure?



      3) For the highest cost row, the one referenced above, it has a Min/Max grant of almost 2GB. Does that mean that when we run the create procedure statement it asked for 2gb of memory? Or is this plan being used when the proc is called ? I suppose this ties into the answer from question 2



      4) Why in some cases we have Min/Max grant KB > 0 and Min/Max used grant kb > 0, but percent memory grant used is null ?



      We are running SQL Server 2012.



      Thanks,
      Kevin







      sql-server sql-server-2012 execution-plan sp-blitzcache






      share|improve this question









      New contributor




      kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 5 hours ago









      Randi Vertongen

      3,791823




      3,791823






      New contributor




      kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 hours ago









      kevinnwhatkevinnwhat

      132




      132




      New contributor




      kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      kevinnwhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          4














          Rephrased your questions a little:



          Q: Why multiple rows for the same plan handle?



          A: Because a plan can include multiple statements.



          Q: Why does a proc have multiple lines in sp_BlitzCache?



          Similar to above: because a stored proc can have multiple statements in it. You'll see one line for the entire proc's metrics, and a line for each statement in it.



          Q: When I see "CREATE PROC" does that mean the proc was created?



          No, that's just how SQL Server stores the queries in a stored procedure. It shows you the contents of the proc.



          Q: Why is the memory granted different from memory used?



          Because the grant is calculated before the query starts using memory. It's kinda like you asking for money to go to the store - you may not use all of the memory if they don't have all the stuff you wanted at the store. You may end up only using some of your money.






          share|improve this answer























          • Got it thanks Brent.

            – kevinnwhat
            5 hours ago










          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
          );



          );






          kevinnwhat is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f232744%2fsp-blitzcache-against-one-stored-procedure%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









          4














          Rephrased your questions a little:



          Q: Why multiple rows for the same plan handle?



          A: Because a plan can include multiple statements.



          Q: Why does a proc have multiple lines in sp_BlitzCache?



          Similar to above: because a stored proc can have multiple statements in it. You'll see one line for the entire proc's metrics, and a line for each statement in it.



          Q: When I see "CREATE PROC" does that mean the proc was created?



          No, that's just how SQL Server stores the queries in a stored procedure. It shows you the contents of the proc.



          Q: Why is the memory granted different from memory used?



          Because the grant is calculated before the query starts using memory. It's kinda like you asking for money to go to the store - you may not use all of the memory if they don't have all the stuff you wanted at the store. You may end up only using some of your money.






          share|improve this answer























          • Got it thanks Brent.

            – kevinnwhat
            5 hours ago















          4














          Rephrased your questions a little:



          Q: Why multiple rows for the same plan handle?



          A: Because a plan can include multiple statements.



          Q: Why does a proc have multiple lines in sp_BlitzCache?



          Similar to above: because a stored proc can have multiple statements in it. You'll see one line for the entire proc's metrics, and a line for each statement in it.



          Q: When I see "CREATE PROC" does that mean the proc was created?



          No, that's just how SQL Server stores the queries in a stored procedure. It shows you the contents of the proc.



          Q: Why is the memory granted different from memory used?



          Because the grant is calculated before the query starts using memory. It's kinda like you asking for money to go to the store - you may not use all of the memory if they don't have all the stuff you wanted at the store. You may end up only using some of your money.






          share|improve this answer























          • Got it thanks Brent.

            – kevinnwhat
            5 hours ago













          4












          4








          4







          Rephrased your questions a little:



          Q: Why multiple rows for the same plan handle?



          A: Because a plan can include multiple statements.



          Q: Why does a proc have multiple lines in sp_BlitzCache?



          Similar to above: because a stored proc can have multiple statements in it. You'll see one line for the entire proc's metrics, and a line for each statement in it.



          Q: When I see "CREATE PROC" does that mean the proc was created?



          No, that's just how SQL Server stores the queries in a stored procedure. It shows you the contents of the proc.



          Q: Why is the memory granted different from memory used?



          Because the grant is calculated before the query starts using memory. It's kinda like you asking for money to go to the store - you may not use all of the memory if they don't have all the stuff you wanted at the store. You may end up only using some of your money.






          share|improve this answer













          Rephrased your questions a little:



          Q: Why multiple rows for the same plan handle?



          A: Because a plan can include multiple statements.



          Q: Why does a proc have multiple lines in sp_BlitzCache?



          Similar to above: because a stored proc can have multiple statements in it. You'll see one line for the entire proc's metrics, and a line for each statement in it.



          Q: When I see "CREATE PROC" does that mean the proc was created?



          No, that's just how SQL Server stores the queries in a stored procedure. It shows you the contents of the proc.



          Q: Why is the memory granted different from memory used?



          Because the grant is calculated before the query starts using memory. It's kinda like you asking for money to go to the store - you may not use all of the memory if they don't have all the stuff you wanted at the store. You may end up only using some of your money.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 5 hours ago









          Brent OzarBrent Ozar

          35.4k19108240




          35.4k19108240












          • Got it thanks Brent.

            – kevinnwhat
            5 hours ago

















          • Got it thanks Brent.

            – kevinnwhat
            5 hours ago
















          Got it thanks Brent.

          – kevinnwhat
          5 hours ago





          Got it thanks Brent.

          – kevinnwhat
          5 hours ago










          kevinnwhat is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          kevinnwhat is a new contributor. Be nice, and check out our Code of Conduct.












          kevinnwhat is a new contributor. Be nice, and check out our Code of Conduct.











          kevinnwhat is a new contributor. Be nice, and check out our Code of Conduct.














          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%2f232744%2fsp-blitzcache-against-one-stored-procedure%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

          Bett Inhaltsverzeichnis Geschichte | Bettformen | Bettgrößen | Andere Bezeichnungen | Bettenmangel | Betten in der bildenden Kunst | Schlafmedizinische Gesichtspunkte | Siehe auch | Literatur | Weblinks | Einzelnachweise | NavigationsmenüBett, Bettstatt, BettstelleCommons: BettBabybetten: Anwendung, Ausstattungsmerkmale und VergleichskriterienWasserbetten. Vorurteile im TestHapfnNursch10.1007/s11818-012-0584-74006250-8AKS4329276-8

          Luksemburg Sisukord Nimi | Asend | Loodus | Riigikord | Haldusjaotus | Rahvastik | Riigikaitse | Majandus | Taristu | Ajalugu | Eesti ja Luksemburgi suhted | Haridus | Kultuur | Vaata ka | Viited | Välislingid | Navigeerimismenüü50° N, 6° EÜlevaade Luksemburgi kaitsealadest.Luksemburgi rahvaarv. Statistikaamet.World Bank'i andmebaasÜlevaade Luksemburgi loodusest.Ülevaade Luksemburgi metsadest.Guy Colling. "Red List of the Vascular Plants of Luxembourg." Travaux scientifiques du Musée national d’histoire naturelle Luxembourg. 2005.Luxembourg’s biodiversity at risk.Maailma kahepaiksete andmebaas.Denis Lepage. "Luxembourg." Avibase.Ülevaade temperatuuridest. Luksemburgi meteoroloogiateenistus.Ülevaade Luksemburgist. Euroopa Liidu esinduse koduleht.Système politique. TerritoireÜlevaade Luksemburgi rahvastikust. Luksemburgi statistikaamet.Luksemburgi rahvastik. Luksemburgi statistikaamet.The World FactbookMonique Borsenberger, Paul Dickes. "Religions au Luxembourg. Quelle évolution entre 1999-2008". Luksemburgi statistikaamet. 2011.Luksemburgi peapiiskopkond. Catholic-Hierarchy.Luksemburgi armee koduleht.Luksemburgi armee relvastus.Eesti Välisministeerium.Luksemburgi rahvastik. Luksemburgi statistikaamet.Luksemburgi Eesti Seltsi koduleht.Helen Eelrand. "Raadio, mis muutis maailma." Eesti Päevaleht. 13. märts 2004.Ülevaade Luksemburgi haridussüsteemist.Ülevaade Luksemburgi keskkoolidest.Luksemburgr

          Valle di Casies Indice Geografia fisica | Origini del nome | Storia | Società | Amministrazione | Sport | Note | Bibliografia | Voci correlate | Altri progetti | Collegamenti esterni | Menu di navigazione46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)Sito istituzionaleAstat Censimento della popolazione 2011 - Determinazione della consistenza dei tre gruppi linguistici della Provincia Autonoma di Bolzano-Alto Adige - giugno 2012Numeri e fattiValle di CasiesDato IstatTabella dei gradi/giorno dei Comuni italiani raggruppati per Regione e Provincia26 agosto 1993, n. 412Heraldry of the World: GsiesStatistiche I.StatValCasies.comWikimedia CommonsWikimedia CommonsValle di CasiesSito ufficialeValle di CasiesMM14870458910042978-6