What's the formula for calculating Key Efficiency, Key Buffer Used, and Query Cache Hitrate in MySql?












7















Now, I have retrieved some dates from table of 'GLOBAL_STATUS' and 'GLOBAL_VARIABLES' by MySQL DB named information_schema .



I can retrieve




  • key_buffer_size

  • key_cache_block_size

  • query_cache_limit


  • Query_cache_size... and so on...



    But, I don't know how to calculate the rate of Key hitrate, Key buffer used,and query cache hitrate




so, someone can get the formula about those, such as
? / ? * 100% = ?










share|improve this question





























    7















    Now, I have retrieved some dates from table of 'GLOBAL_STATUS' and 'GLOBAL_VARIABLES' by MySQL DB named information_schema .



    I can retrieve




    • key_buffer_size

    • key_cache_block_size

    • query_cache_limit


    • Query_cache_size... and so on...



      But, I don't know how to calculate the rate of Key hitrate, Key buffer used,and query cache hitrate




    so, someone can get the formula about those, such as
    ? / ? * 100% = ?










    share|improve this question



























      7












      7








      7


      2






      Now, I have retrieved some dates from table of 'GLOBAL_STATUS' and 'GLOBAL_VARIABLES' by MySQL DB named information_schema .



      I can retrieve




      • key_buffer_size

      • key_cache_block_size

      • query_cache_limit


      • Query_cache_size... and so on...



        But, I don't know how to calculate the rate of Key hitrate, Key buffer used,and query cache hitrate




      so, someone can get the formula about those, such as
      ? / ? * 100% = ?










      share|improve this question
















      Now, I have retrieved some dates from table of 'GLOBAL_STATUS' and 'GLOBAL_VARIABLES' by MySQL DB named information_schema .



      I can retrieve




      • key_buffer_size

      • key_cache_block_size

      • query_cache_limit


      • Query_cache_size... and so on...



        But, I don't know how to calculate the rate of Key hitrate, Key buffer used,and query cache hitrate




      so, someone can get the formula about those, such as
      ? / ? * 100% = ?







      mysql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 28 '12 at 6:25









      Abdul Manaf

      6,291105376




      6,291105376










      asked Jun 28 '12 at 2:27









      Xia YuXia Yu

      3615




      3615






















          4 Answers
          4






          active

          oldest

          votes


















          10














          For your reference i am trying to explain some concepts also.



          Key hit rate



          There are basically two forms of key hit rate



          1.Key Read Efficiency




          Key Reads: The number of physical reads of a key block from disk.



          Key Read Request: The number of requests to read a key block from the
          cache.




          Key Read Efficiency = [1 - (Key_reads/Key_read_requests)]*100



          Key Read Efficiency: The ratio of the number of physical reads of a
          key block from the cache to the number of requests to read a key block
          from the cache in percentage. The MySQL performance is good if the
          value of Key Read Efficiency is 90 percent and above. Increasing the
          size of the cache improves the value of Key Read Efficiency and hence
          an improved the performance.




          2.Key Write Efficiency




          Key Writes: The number of physical writes of a key block to disk.



          Key Write Request: The number of requests to write a key block to the
          cache.




          Key Write Efficiency=(Key_write/Key_write_requests)*100



          Key Write Efficiency: The ratio of the number of physical writes of a
          key block to the cache to the number of requests to write a key block
          to the cache in percentage. For a good performance of the MySQL
          server, the value of Key Write Efficiency must be 90 percent and
          above. If it is found less, then you can increase the size of the
          cache to improve the performance.




          Key Buffer Used



          Find value of key_buffer_size as show variables like 'key_buffer_size';



          convert it into MB.



          Find the All MyISAM index Size :




          SELECT SUM(INDEX_LENGTH)/(1024*1024) 'Index Size' FROM
          information_schema.TABLES where ENGINE='MyISAM' AND TABLE_SCHEMA NOT
          IN('mysql','information_schema');




          Find



          (Index Size)/key_buffer_size(in MB) * 100



          if result is (<=100 ) then your all indexes are cached into key_buffer



          if result is (>100) then your all indexes are not cached into
          key_buffer you may gain performance boost by increasing
          key_buffer_size.




          query cache hitrate




          Hit rate = Qcache_hits / (Qcache_hits + Com_select) * 100



          Insert rate = Qcache_inserts / (Qcache_hits + Com_select) * 100



          Prune rate = (Qcache_lowmem_prunes / Qcache_inserts) * 100







          share|improve this answer


























          • Very nice. You makes me question. Thank you very much, this is my first time to ask a question in English!

            – Xia Yu
            Jun 28 '12 at 10:35











          • oh great !!!.Hope that answer will help you.

            – Abdul Manaf
            Jun 28 '12 at 10:38











          • Why is the key read efficiency "1-" but the key write efficiency is not?

            – user11575
            Sep 12 '12 at 16:48



















          0














          For those using MySQL Administrator, here is a nice script I found, which shows the main interesting values.



          Worked perfectly for me (Win7 x64, MySQL 5.1.3 on Debian).



          Thanks to the guy who wrote it !






          share|improve this answer































            0














            I don't frequent here but the formula in the top answer for Hit Rate is not right. Please see Optimizing MySQL query_cache_size for the proper formula.






            share|improve this answer


























            • I appreciate that you don't have the necessary reputation to post comments, but soon you will!

              – Max Vernon
              Sep 8 '14 at 20:09



















            0














            (Now it is 2019.)



            I suggest that the question is moot since you should not be using MyISAM. Instead, you should be using InnoDB, which has different metrics.



            And the Query Cache has been removed from MySQL 8.0. And it is not usable in many multi-master setup, including Galera and Group Replication.






            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%2f20083%2fwhats-the-formula-for-calculating-key-efficiency-key-buffer-used-and-query-ca%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              10














              For your reference i am trying to explain some concepts also.



              Key hit rate



              There are basically two forms of key hit rate



              1.Key Read Efficiency




              Key Reads: The number of physical reads of a key block from disk.



              Key Read Request: The number of requests to read a key block from the
              cache.




              Key Read Efficiency = [1 - (Key_reads/Key_read_requests)]*100



              Key Read Efficiency: The ratio of the number of physical reads of a
              key block from the cache to the number of requests to read a key block
              from the cache in percentage. The MySQL performance is good if the
              value of Key Read Efficiency is 90 percent and above. Increasing the
              size of the cache improves the value of Key Read Efficiency and hence
              an improved the performance.




              2.Key Write Efficiency




              Key Writes: The number of physical writes of a key block to disk.



              Key Write Request: The number of requests to write a key block to the
              cache.




              Key Write Efficiency=(Key_write/Key_write_requests)*100



              Key Write Efficiency: The ratio of the number of physical writes of a
              key block to the cache to the number of requests to write a key block
              to the cache in percentage. For a good performance of the MySQL
              server, the value of Key Write Efficiency must be 90 percent and
              above. If it is found less, then you can increase the size of the
              cache to improve the performance.




              Key Buffer Used



              Find value of key_buffer_size as show variables like 'key_buffer_size';



              convert it into MB.



              Find the All MyISAM index Size :




              SELECT SUM(INDEX_LENGTH)/(1024*1024) 'Index Size' FROM
              information_schema.TABLES where ENGINE='MyISAM' AND TABLE_SCHEMA NOT
              IN('mysql','information_schema');




              Find



              (Index Size)/key_buffer_size(in MB) * 100



              if result is (<=100 ) then your all indexes are cached into key_buffer



              if result is (>100) then your all indexes are not cached into
              key_buffer you may gain performance boost by increasing
              key_buffer_size.




              query cache hitrate




              Hit rate = Qcache_hits / (Qcache_hits + Com_select) * 100



              Insert rate = Qcache_inserts / (Qcache_hits + Com_select) * 100



              Prune rate = (Qcache_lowmem_prunes / Qcache_inserts) * 100







              share|improve this answer


























              • Very nice. You makes me question. Thank you very much, this is my first time to ask a question in English!

                – Xia Yu
                Jun 28 '12 at 10:35











              • oh great !!!.Hope that answer will help you.

                – Abdul Manaf
                Jun 28 '12 at 10:38











              • Why is the key read efficiency "1-" but the key write efficiency is not?

                – user11575
                Sep 12 '12 at 16:48
















              10














              For your reference i am trying to explain some concepts also.



              Key hit rate



              There are basically two forms of key hit rate



              1.Key Read Efficiency




              Key Reads: The number of physical reads of a key block from disk.



              Key Read Request: The number of requests to read a key block from the
              cache.




              Key Read Efficiency = [1 - (Key_reads/Key_read_requests)]*100



              Key Read Efficiency: The ratio of the number of physical reads of a
              key block from the cache to the number of requests to read a key block
              from the cache in percentage. The MySQL performance is good if the
              value of Key Read Efficiency is 90 percent and above. Increasing the
              size of the cache improves the value of Key Read Efficiency and hence
              an improved the performance.




              2.Key Write Efficiency




              Key Writes: The number of physical writes of a key block to disk.



              Key Write Request: The number of requests to write a key block to the
              cache.




              Key Write Efficiency=(Key_write/Key_write_requests)*100



              Key Write Efficiency: The ratio of the number of physical writes of a
              key block to the cache to the number of requests to write a key block
              to the cache in percentage. For a good performance of the MySQL
              server, the value of Key Write Efficiency must be 90 percent and
              above. If it is found less, then you can increase the size of the
              cache to improve the performance.




              Key Buffer Used



              Find value of key_buffer_size as show variables like 'key_buffer_size';



              convert it into MB.



              Find the All MyISAM index Size :




              SELECT SUM(INDEX_LENGTH)/(1024*1024) 'Index Size' FROM
              information_schema.TABLES where ENGINE='MyISAM' AND TABLE_SCHEMA NOT
              IN('mysql','information_schema');




              Find



              (Index Size)/key_buffer_size(in MB) * 100



              if result is (<=100 ) then your all indexes are cached into key_buffer



              if result is (>100) then your all indexes are not cached into
              key_buffer you may gain performance boost by increasing
              key_buffer_size.




              query cache hitrate




              Hit rate = Qcache_hits / (Qcache_hits + Com_select) * 100



              Insert rate = Qcache_inserts / (Qcache_hits + Com_select) * 100



              Prune rate = (Qcache_lowmem_prunes / Qcache_inserts) * 100







              share|improve this answer


























              • Very nice. You makes me question. Thank you very much, this is my first time to ask a question in English!

                – Xia Yu
                Jun 28 '12 at 10:35











              • oh great !!!.Hope that answer will help you.

                – Abdul Manaf
                Jun 28 '12 at 10:38











              • Why is the key read efficiency "1-" but the key write efficiency is not?

                – user11575
                Sep 12 '12 at 16:48














              10












              10








              10







              For your reference i am trying to explain some concepts also.



              Key hit rate



              There are basically two forms of key hit rate



              1.Key Read Efficiency




              Key Reads: The number of physical reads of a key block from disk.



              Key Read Request: The number of requests to read a key block from the
              cache.




              Key Read Efficiency = [1 - (Key_reads/Key_read_requests)]*100



              Key Read Efficiency: The ratio of the number of physical reads of a
              key block from the cache to the number of requests to read a key block
              from the cache in percentage. The MySQL performance is good if the
              value of Key Read Efficiency is 90 percent and above. Increasing the
              size of the cache improves the value of Key Read Efficiency and hence
              an improved the performance.




              2.Key Write Efficiency




              Key Writes: The number of physical writes of a key block to disk.



              Key Write Request: The number of requests to write a key block to the
              cache.




              Key Write Efficiency=(Key_write/Key_write_requests)*100



              Key Write Efficiency: The ratio of the number of physical writes of a
              key block to the cache to the number of requests to write a key block
              to the cache in percentage. For a good performance of the MySQL
              server, the value of Key Write Efficiency must be 90 percent and
              above. If it is found less, then you can increase the size of the
              cache to improve the performance.




              Key Buffer Used



              Find value of key_buffer_size as show variables like 'key_buffer_size';



              convert it into MB.



              Find the All MyISAM index Size :




              SELECT SUM(INDEX_LENGTH)/(1024*1024) 'Index Size' FROM
              information_schema.TABLES where ENGINE='MyISAM' AND TABLE_SCHEMA NOT
              IN('mysql','information_schema');




              Find



              (Index Size)/key_buffer_size(in MB) * 100



              if result is (<=100 ) then your all indexes are cached into key_buffer



              if result is (>100) then your all indexes are not cached into
              key_buffer you may gain performance boost by increasing
              key_buffer_size.




              query cache hitrate




              Hit rate = Qcache_hits / (Qcache_hits + Com_select) * 100



              Insert rate = Qcache_inserts / (Qcache_hits + Com_select) * 100



              Prune rate = (Qcache_lowmem_prunes / Qcache_inserts) * 100







              share|improve this answer















              For your reference i am trying to explain some concepts also.



              Key hit rate



              There are basically two forms of key hit rate



              1.Key Read Efficiency




              Key Reads: The number of physical reads of a key block from disk.



              Key Read Request: The number of requests to read a key block from the
              cache.




              Key Read Efficiency = [1 - (Key_reads/Key_read_requests)]*100



              Key Read Efficiency: The ratio of the number of physical reads of a
              key block from the cache to the number of requests to read a key block
              from the cache in percentage. The MySQL performance is good if the
              value of Key Read Efficiency is 90 percent and above. Increasing the
              size of the cache improves the value of Key Read Efficiency and hence
              an improved the performance.




              2.Key Write Efficiency




              Key Writes: The number of physical writes of a key block to disk.



              Key Write Request: The number of requests to write a key block to the
              cache.




              Key Write Efficiency=(Key_write/Key_write_requests)*100



              Key Write Efficiency: The ratio of the number of physical writes of a
              key block to the cache to the number of requests to write a key block
              to the cache in percentage. For a good performance of the MySQL
              server, the value of Key Write Efficiency must be 90 percent and
              above. If it is found less, then you can increase the size of the
              cache to improve the performance.




              Key Buffer Used



              Find value of key_buffer_size as show variables like 'key_buffer_size';



              convert it into MB.



              Find the All MyISAM index Size :




              SELECT SUM(INDEX_LENGTH)/(1024*1024) 'Index Size' FROM
              information_schema.TABLES where ENGINE='MyISAM' AND TABLE_SCHEMA NOT
              IN('mysql','information_schema');




              Find



              (Index Size)/key_buffer_size(in MB) * 100



              if result is (<=100 ) then your all indexes are cached into key_buffer



              if result is (>100) then your all indexes are not cached into
              key_buffer you may gain performance boost by increasing
              key_buffer_size.




              query cache hitrate




              Hit rate = Qcache_hits / (Qcache_hits + Com_select) * 100



              Insert rate = Qcache_inserts / (Qcache_hits + Com_select) * 100



              Prune rate = (Qcache_lowmem_prunes / Qcache_inserts) * 100








              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jun 28 '12 at 6:32

























              answered Jun 28 '12 at 5:58









              Abdul ManafAbdul Manaf

              6,291105376




              6,291105376













              • Very nice. You makes me question. Thank you very much, this is my first time to ask a question in English!

                – Xia Yu
                Jun 28 '12 at 10:35











              • oh great !!!.Hope that answer will help you.

                – Abdul Manaf
                Jun 28 '12 at 10:38











              • Why is the key read efficiency "1-" but the key write efficiency is not?

                – user11575
                Sep 12 '12 at 16:48



















              • Very nice. You makes me question. Thank you very much, this is my first time to ask a question in English!

                – Xia Yu
                Jun 28 '12 at 10:35











              • oh great !!!.Hope that answer will help you.

                – Abdul Manaf
                Jun 28 '12 at 10:38











              • Why is the key read efficiency "1-" but the key write efficiency is not?

                – user11575
                Sep 12 '12 at 16:48

















              Very nice. You makes me question. Thank you very much, this is my first time to ask a question in English!

              – Xia Yu
              Jun 28 '12 at 10:35





              Very nice. You makes me question. Thank you very much, this is my first time to ask a question in English!

              – Xia Yu
              Jun 28 '12 at 10:35













              oh great !!!.Hope that answer will help you.

              – Abdul Manaf
              Jun 28 '12 at 10:38





              oh great !!!.Hope that answer will help you.

              – Abdul Manaf
              Jun 28 '12 at 10:38













              Why is the key read efficiency "1-" but the key write efficiency is not?

              – user11575
              Sep 12 '12 at 16:48





              Why is the key read efficiency "1-" but the key write efficiency is not?

              – user11575
              Sep 12 '12 at 16:48













              0














              For those using MySQL Administrator, here is a nice script I found, which shows the main interesting values.



              Worked perfectly for me (Win7 x64, MySQL 5.1.3 on Debian).



              Thanks to the guy who wrote it !






              share|improve this answer




























                0














                For those using MySQL Administrator, here is a nice script I found, which shows the main interesting values.



                Worked perfectly for me (Win7 x64, MySQL 5.1.3 on Debian).



                Thanks to the guy who wrote it !






                share|improve this answer


























                  0












                  0








                  0







                  For those using MySQL Administrator, here is a nice script I found, which shows the main interesting values.



                  Worked perfectly for me (Win7 x64, MySQL 5.1.3 on Debian).



                  Thanks to the guy who wrote it !






                  share|improve this answer













                  For those using MySQL Administrator, here is a nice script I found, which shows the main interesting values.



                  Worked perfectly for me (Win7 x64, MySQL 5.1.3 on Debian).



                  Thanks to the guy who wrote it !







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 21 '13 at 15:50









                  BenjBenj

                  1012




                  1012























                      0














                      I don't frequent here but the formula in the top answer for Hit Rate is not right. Please see Optimizing MySQL query_cache_size for the proper formula.






                      share|improve this answer


























                      • I appreciate that you don't have the necessary reputation to post comments, but soon you will!

                        – Max Vernon
                        Sep 8 '14 at 20:09
















                      0














                      I don't frequent here but the formula in the top answer for Hit Rate is not right. Please see Optimizing MySQL query_cache_size for the proper formula.






                      share|improve this answer


























                      • I appreciate that you don't have the necessary reputation to post comments, but soon you will!

                        – Max Vernon
                        Sep 8 '14 at 20:09














                      0












                      0








                      0







                      I don't frequent here but the formula in the top answer for Hit Rate is not right. Please see Optimizing MySQL query_cache_size for the proper formula.






                      share|improve this answer















                      I don't frequent here but the formula in the top answer for Hit Rate is not right. Please see Optimizing MySQL query_cache_size for the proper formula.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Sep 8 '14 at 20:09









                      Max Vernon

                      50.8k13112224




                      50.8k13112224










                      answered Sep 8 '14 at 19:39









                      mschuettmschuett

                      1013




                      1013













                      • I appreciate that you don't have the necessary reputation to post comments, but soon you will!

                        – Max Vernon
                        Sep 8 '14 at 20:09



















                      • I appreciate that you don't have the necessary reputation to post comments, but soon you will!

                        – Max Vernon
                        Sep 8 '14 at 20:09

















                      I appreciate that you don't have the necessary reputation to post comments, but soon you will!

                      – Max Vernon
                      Sep 8 '14 at 20:09





                      I appreciate that you don't have the necessary reputation to post comments, but soon you will!

                      – Max Vernon
                      Sep 8 '14 at 20:09











                      0














                      (Now it is 2019.)



                      I suggest that the question is moot since you should not be using MyISAM. Instead, you should be using InnoDB, which has different metrics.



                      And the Query Cache has been removed from MySQL 8.0. And it is not usable in many multi-master setup, including Galera and Group Replication.






                      share|improve this answer




























                        0














                        (Now it is 2019.)



                        I suggest that the question is moot since you should not be using MyISAM. Instead, you should be using InnoDB, which has different metrics.



                        And the Query Cache has been removed from MySQL 8.0. And it is not usable in many multi-master setup, including Galera and Group Replication.






                        share|improve this answer


























                          0












                          0








                          0







                          (Now it is 2019.)



                          I suggest that the question is moot since you should not be using MyISAM. Instead, you should be using InnoDB, which has different metrics.



                          And the Query Cache has been removed from MySQL 8.0. And it is not usable in many multi-master setup, including Galera and Group Replication.






                          share|improve this answer













                          (Now it is 2019.)



                          I suggest that the question is moot since you should not be using MyISAM. Instead, you should be using InnoDB, which has different metrics.



                          And the Query Cache has been removed from MySQL 8.0. And it is not usable in many multi-master setup, including Galera and Group Replication.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 28 mins ago









                          Rick JamesRick James

                          42.7k22258




                          42.7k22258






























                              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%2f20083%2fwhats-the-formula-for-calculating-key-efficiency-key-buffer-used-and-query-ca%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

                              Ronny Ackermann

                              Köttigit

                              MySQL 8.0.15 starts normally but any connection hangs