You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-db/mytop/files/mytop-1.6-queries-vs-questi...

73 lines
3.3 KiB

In MySQL 5.0.72 the Questions variable was changed to only contain the number
of client-initiated queries, NOT the number of overall queries. This caused
problems with the select/insert/update/delete percentages because Com_* was
still based on the overall queries.
MySQL 5.0.76 introduced a new variable 'Queries' with the behavior of the old
Questions variable.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
MySQL-Bug: 41131
MySQL-Bug-URL: http://bugs.mysql.com/?id=41131
====
Revision 2:
The first revision missed changing the instances of $OLD_STATUS{Questions}.
diff -Nuar mytop-1.6.orig/mytop mytop-1.6/mytop
--- mytop-1.6.orig/mytop 2009-02-14 17:28:38.696187159 -0800
+++ mytop-1.6/mytop 2009-02-14 17:36:31.192890507 -0800
@@ -800,8 +800,15 @@
## Queries per second...
- my $avg_queries_per_sec = sprintf("%.2f", $STATUS{Questions} / $STATUS{Uptime});
- my $num_queries = $STATUS{Questions};
+ my ($num_queries, $old_num_queries);
+ if(defined($STATUS{Queries})) {
+ $num_queries = $STATUS{Queries};
+ $old_num_queries = $OLD_STATUS{Queries};
+ } else {
+ $num_queries = $STATUS{Questions};
+ $old_num_queries = $OLD_STATUS{Questions};
+ }
+ my $avg_queries_per_sec = sprintf("%.2f", $num_queries / $STATUS{Uptime});
my @t = localtime(time);
@@ -820,25 +827,25 @@
printf " Queries: %-5s qps: %4.0f Slow: %7s Se/In/Up/De(%%): %02.0f/%02.0f/%02.0f/%02.0f \n",
- make_short( $STATUS{Questions} ), # q total
- $STATUS{Questions} / $STATUS{Uptime}, # qps, average
+ make_short( $num_queries ), # q total
+ $num_queries / $STATUS{Uptime}, # qps, average
make_short( $STATUS{Slow_queries} ), # slow
# hmm. a Qcache hit is really a select and should be counted.
- 100 * ($STATUS{Com_select} + ($STATUS{Qcache_hits}||0) ) / $STATUS{Questions},
- 100 * ($STATUS{Com_insert} + $STATUS{Com_replace} ) / $STATUS{Questions},
- 100 * ($STATUS{Com_update} ) / $STATUS{Questions},
- 100 * $STATUS{Com_delete} / $STATUS{Questions};
+ 100 * ($STATUS{Com_select} + ($STATUS{Qcache_hits}||0) ) / $num_queries,
+ 100 * ($STATUS{Com_insert} + $STATUS{Com_replace} ) / $num_queries,
+ 100 * ($STATUS{Com_update} ) / $num_queries,
+ 100 * $STATUS{Com_delete} / $num_queries;
$lines_left--;
if ($t_delta)
{
- my $q_diff = ( $STATUS{Questions} - $OLD_STATUS{Questions} );
-# print("q_diff: $STATUS{Questions} - $OLD_STATUS{Questions} / $t_delta = $q_diff\n");
+ my $q_diff = ( $num_queries - $old_num_queries );
+# print("q_diff: $num_queries - $old_num_queries / $t_delta = $q_diff\n");
printf(" qps now: %4.0f Slow qps: %3.1f Threads: %4.0f (%4.0f/%4.0f) %02.0f/%02.0f/%02.0f/%02.0f \n",
- ( $STATUS{Questions} - $OLD_STATUS{Questions} ) / $t_delta,
+ ( $num_queries - $old_num_queries ) / $t_delta,
( # slow now (qps)
($STATUS{Slow_queries} ) ?
( $STATUS{Slow_queries} - $OLD_STATUS{Slow_queries} ) / $t_delta :