pt-upgrade should have an option to ignore query times

Registered by Matthew B on 2015-12-23

Many times I find myself just needing to check if queries return different results. I don't care if the execution times are different. pt-upgrade is a great tool for processing a slow log and comparing two different MySQL hosts. But the reports are hard to read when 99% of the report is telling me query 1 executed 34x faster on one host vs another.

This patch adds a new flag, --ignore-query-time-diffs, which does just this. Now I am able to compare a 2GB slow log between 5.1 and 5.6 and only concern myself with the 5 or so queries that produced different results rather than sifting through the muck.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
Matthew B
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

[percona@553569-DB03 ~]$ diff -ur /usr/bin/pt-upgrade ./pt-upgrade
--- /usr/bin/pt-upgrade 2014-02-20 19:11:00.000000000 +1100
+++ ./pt-upgrade 2015-12-24 09:13:48.311110892 +1100
@@ -9438,6 +9438,7 @@
       read_only => $o->get('read-only') ? 1 : 0,
       allowed_errors => $o->get('continue-on-error') ? 100 : 0,
       progress => $o->get('progress'),
+ ignore_times => $o->get('ignore-query-time-diffs'),
    );

    if ( $host1 && $host2 ) {
@@ -9703,6 +9704,7 @@
    my $read_only = $args{read_only};
    my $allowed_errors = $args{allowed_errors} || 0;
    my $progress = $args{progress};
+ my $ignore_times = $args{ignore_times} || 0;

    # Get set up to execute and compare queries.
    my $clear_warnings_sql = "SELECT * FROM $upgrade_table LIMIT 1 "
@@ -9767,6 +9769,7 @@
                results1 => $results1,
                results2 => $results2,
                ignore_warnings => $ignore_warnings,
+ ignore_times => $ignore_times,
             );
          }
       };
@@ -9911,6 +9914,7 @@
    my $ignore_warnings = $args{ignore_warnings};
    my $allowed_errors = $args{allowed_errors} || 0;
    my $progress = $args{progress};
+ my $ignore_times = $args{ignore_times} || 0;

    my $clear_warnings_sql = "SELECT * FROM $upgrade_table LIMIT 1 "
                           . "/* pt-upgrade clear warnings */";
@@ -9971,6 +9975,7 @@
                results1 => $results1,
                results2 => $results2,
                ignore_warnings => $ignore_warnings,
+ ignore_times => $ignore_times,
             );
          }
       };
@@ -10008,6 +10013,7 @@

    # Optional args
    my $ignore_warnings = $args{ignore_warnings};
+ my $ignore_times = $args{ignore_times};

    if ( $results1->{error} && $results2->{error} ) {
       PTDEBUG && _d('Failed query');
@@ -10029,10 +10035,13 @@
       );
    }
    else {
- my $query_time_diffs = diff_query_times(
- query_time1 => $results1->{query_time},
- query_time2 => $results2->{query_time},
- );
+ my $query_time_diffs = 0;
+ if ( ! $ignore_times ) {
+ $query_time_diffs = diff_query_times(
+ query_time1 => $results1->{query_time},
+ query_time2 => $results2->{query_time},
+ );
+ }

       my $warning_diffs = diff_warnings(
          warnings1 => $results1->{warnings},
@@ -10845,6 +10854,12 @@

 Ignore these MySQL warning codes when comparing warnings.

+=item --ignore-query-time-diffs
+
+When comparing the execution times of queries between hosts or between saved
+results and a host, ignore any query time differences. This is useful if
+you only care about seeing queries that produce difference results.
+
 =item --log

 type: string

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.