{"id":1609,"date":"2009-11-13T13:26:31","date_gmt":"2009-11-13T11:26:31","guid":{"rendered":"http:\/\/code.openark.org\/blog\/?p=1609"},"modified":"2009-11-13T13:26:31","modified_gmt":"2009-11-13T11:26:31","slug":"questions-or-queries","status":"publish","type":"post","link":"https:\/\/code.openark.org\/blog\/mysql\/questions-or-queries","title":{"rendered":"questions or queries?"},"content":{"rendered":"<p>I&#8217;ve hit a recent change which took me by surprise.<\/p>\n<p>I was used to checking for the &#8216;<strong>questions<\/strong>&#8216; global status variables to see the total amount of queries the server performs. So, for example, I could run <strong>com_select<\/strong>\/<strong>questions<\/strong> to learn the SELECT ratio out of all queries.<\/p>\n<p>Apparently, as of <strong>5.0.72<\/strong>&#8211;<strong>5.0.76<\/strong> &amp; <strong>5.1.31<\/strong> this has changed. A new status variable was introduced, called &#8216;<strong>queries<\/strong>&#8216;.<\/p>\n<p>The change being? <strong>questions<\/strong> does not any longer indicate the number of queries the server has executed: only the number of queries requested by the client (so, calling on a stored routine only counts as <strong>1<\/strong>, regardless of how many queries the routine executes). The new <strong>queries<\/strong> variable indicates the amount of server queries issued (see the <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/server-status-variables.html#statvar_Queries\">5.0<\/a> and <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/server-status-variables.html#statvar_Queries\">5.1<\/a> docs for details).<\/p>\n<p>So, as of <strong>5.0.72<\/strong> or <strong>5.1.31<\/strong>, the calculation should be <strong>com_select<\/strong>\/<strong>com_queries<\/strong> (or <strong>com_select_<em>diff<\/em><\/strong>\/<strong>com_queries_<em>diff<\/em><\/strong>) to learn the SELECT ratio of all queries. I learned this due to a bug report on <em>mycheckpoint<\/em>, which presented some 10265% SELECT ratio&#8230;<\/p>\n<p>My take on this is that it could have been worked out differently: instead of changing the meaning of an existing variable, <strong>questions<\/strong> could have remained as it was, with the introduction of, say, <strong>client_questions<\/strong>, which would only indicate client number of issued queries.<\/p>\n<p>I believe changing the meaning of status variables at such late versions (<strong>5.0.76<\/strong> is quite late!) invites trouble: code that used to work on already then-stable versions (e.g. <strong>5.0.51<\/strong>) would behave differently after upgrade. Such changes should best take place while still in BETA phase.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve hit a recent change which took me by surprise. I was used to checking for the &#8216;questions&#8216; global status variables to see the total amount of queries the server performs. So, for example, I could run com_select\/questions to learn the SELECT ratio out of all queries. Apparently, as of 5.0.72&#8211;5.0.76 &amp; 5.1.31 this has [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[5],"tags":[46,49],"class_list":["post-1609","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-monitoring","tag-mycheckpoint"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bZZp-pX","_links":{"self":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/1609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/comments?post=1609"}],"version-history":[{"count":7,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/1609\/revisions"}],"predecessor-version":[{"id":1616,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/1609\/revisions\/1616"}],"wp:attachment":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/media?parent=1609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/categories?post=1609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/tags?post=1609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}