mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-18 16:40:23 +00:00
pqd: Removed show-all, shorten, select & print-iterations
This commit is contained in:
@@ -3488,7 +3488,7 @@ sub _parse_packet {
|
||||
sub port_number {
|
||||
my ( $self, $port ) = @_;
|
||||
return unless $port;
|
||||
return $port eq 'mysql' ? 3306 : $port;
|
||||
return $port eq 'mysql' ? 3306 : $port;
|
||||
}
|
||||
|
||||
sub _d {
|
||||
@@ -6511,8 +6511,7 @@ sub BUILDARGS {
|
||||
my $self = {
|
||||
%$args,
|
||||
options => {
|
||||
show_all => $o->get('show-all'),
|
||||
shorten => $o->get('shorten'),
|
||||
shorten => 1024,
|
||||
report_all => $o->get('report-all'),
|
||||
report_histogram => $o->get('report-histogram'),
|
||||
},
|
||||
@@ -6642,10 +6641,7 @@ sub header {
|
||||
|
||||
push @result, $self->make_global_header();
|
||||
|
||||
my $attribs = $self->sort_attribs(
|
||||
($args{select} ? $args{select} : $ea->get_attributes()),
|
||||
$ea,
|
||||
);
|
||||
my $attribs = $self->sort_attribs( $ea );
|
||||
|
||||
foreach my $type ( qw(num innodb) ) {
|
||||
if ( $type eq 'innodb' && @{$attribs->{$type}} ) {
|
||||
@@ -6767,10 +6763,7 @@ sub query_report {
|
||||
. '# ' . ( '#' x 72 ) . "\n\n";
|
||||
}
|
||||
|
||||
my $attribs = $self->sort_attribs(
|
||||
($args{select} ? $args{select} : $ea->get_attributes()),
|
||||
$ea,
|
||||
);
|
||||
my $attribs = $self->sort_attribs( $ea );
|
||||
|
||||
ITEM:
|
||||
foreach my $vals ( @$report_values ) {
|
||||
@@ -6902,10 +6895,7 @@ sub event_report_values {
|
||||
|
||||
my $attribs = $args{attribs};
|
||||
if ( !$attribs ) {
|
||||
$attribs = $self->sort_attribs(
|
||||
($args{select} ? $args{select} : $ea->get_attributes()),
|
||||
$ea
|
||||
);
|
||||
$attribs = $self->sort_attribs( $ea );
|
||||
}
|
||||
|
||||
$vals{attributes} = { map { $_ => [] } qw(num innodb bool string) };
|
||||
@@ -7372,7 +7362,6 @@ sub bool_percents {
|
||||
|
||||
sub format_string_list {
|
||||
my ( $self, $attrib, $vals, $class_cnt ) = @_;
|
||||
my $show_all = $self->{options}->{show_all};
|
||||
|
||||
if ( !exists $vals->{unq} ) {
|
||||
return ($vals->{cnt});
|
||||
@@ -7402,9 +7391,6 @@ sub format_string_list {
|
||||
}
|
||||
my $p = percentage_of($cnt_for->{$str}, $class_cnt);
|
||||
$print_str .= " ($cnt_for->{$str}/$p%)";
|
||||
if ( !$show_all->{$attrib} ) {
|
||||
last if (length $line) + (length $print_str) > LINE_LENGTH - 27;
|
||||
}
|
||||
$line .= "$print_str, ";
|
||||
$i++;
|
||||
}
|
||||
@@ -7419,7 +7405,8 @@ sub format_string_list {
|
||||
}
|
||||
|
||||
sub sort_attribs {
|
||||
my ( $self, $attribs, $ea ) = @_;
|
||||
my ( $self, $ea ) = @_;
|
||||
my $attribs = $ea->get_attributes();
|
||||
return unless $attribs && @$attribs;
|
||||
PTDEBUG && _d("Sorting attribs:", @$attribs);
|
||||
|
||||
@@ -12560,23 +12547,6 @@ sub main {
|
||||
my $pat = $o->read_para_after(__FILE__, qr/MAGIC_history_cols/);
|
||||
$pat =~ s/\s+//g;
|
||||
$pat = qr/^(.*?)_($pat)$/;
|
||||
# Get original --select values.
|
||||
my %select = map { $_ => 1 } @{$o->get('select')};
|
||||
foreach my $col ( @{$tbl->{cols}} ) {
|
||||
my ( $attr, $metric ) = $col =~ $pat;
|
||||
next unless $attr && $metric;
|
||||
$attr = ucfirst $attr if $attr =~ m/_/; # TableParser lowercases
|
||||
# Add history table values to original select values.
|
||||
$select{$attr}++;
|
||||
}
|
||||
|
||||
if ( $o->got('select') ) {
|
||||
# Re-set --select with its original values plus the history
|
||||
# table values.
|
||||
$o->set('select', [sort keys %select]);
|
||||
PTDEBUG && _d("--select after parsing the history table:",
|
||||
@{$o->get('select')});
|
||||
}
|
||||
|
||||
# And tell the QueryReview that it has more work to do.
|
||||
$qv->set_history_options(
|
||||
@@ -13053,9 +13023,9 @@ sub main {
|
||||
PTDEBUG && _d('Iteration', $args->{iter},
|
||||
'started at', ts($iter_start));
|
||||
|
||||
if ( $o->get('print-iterations') ) {
|
||||
print "\n# Iteration $args->{iter} started at ",
|
||||
ts($iter_start), "\n";
|
||||
if ( PTDEBUG ) {
|
||||
_d("\n# Iteration $args->{iter} started at ",
|
||||
ts($iter_start), "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13428,13 +13398,6 @@ sub main {
|
||||
|
||||
my ( $orderby_attrib, $orderby_func ) = split(/:/, $orderby[$i]);
|
||||
|
||||
my %attributes = map {
|
||||
my ($name, @alt) = split(/:/, $_);
|
||||
$name => [$name, @alt];
|
||||
}
|
||||
grep { $_ !~ m/^$groupby\b/ }
|
||||
@{$o->get('select')};
|
||||
|
||||
# Create an EventAggregator for this groupby attrib and
|
||||
# add it to callbacks.
|
||||
my $type_for = {
|
||||
@@ -13451,7 +13414,7 @@ sub main {
|
||||
|
||||
my $ea = new EventAggregator(
|
||||
groupby => $groupby,
|
||||
attributes => { %attributes },
|
||||
attributes => { },
|
||||
worst => $orderby_attrib,
|
||||
attrib_limit => $o->get('attribute-value-limit'),
|
||||
ignore_attributes => $o->get('ignore-attributes'),
|
||||
|
@@ -108,7 +108,7 @@ sub new {
|
||||
keys %$attributes
|
||||
},
|
||||
worst => $args{worst},
|
||||
unroll_limit => $args{unroll_limit} || 1000,
|
||||
unroll_limit => $ENV{PT_QUERY_DIGEST_CHECK_ATTRIB_LIMIT} || 1000,
|
||||
attrib_limit => $args{attrib_limit},
|
||||
result_classes => {},
|
||||
result_globals => {},
|
||||
|
@@ -113,8 +113,7 @@ sub BUILDARGS {
|
||||
my $self = {
|
||||
%$args,
|
||||
options => {
|
||||
show_all => $o->get('show-all'),
|
||||
shorten => $o->get('shorten'),
|
||||
shorten => 1024,
|
||||
report_all => $o->get('report-all'),
|
||||
report_histogram => $o->get('report-histogram'),
|
||||
},
|
||||
@@ -271,10 +270,7 @@ sub header {
|
||||
push @result, $self->make_global_header();
|
||||
|
||||
# Sort the attributes, removing any hidden attributes.
|
||||
my $attribs = $self->sort_attribs(
|
||||
($args{select} ? $args{select} : $ea->get_attributes()),
|
||||
$ea,
|
||||
);
|
||||
my $attribs = $self->sort_attribs( $ea );
|
||||
|
||||
foreach my $type ( qw(num innodb) ) {
|
||||
# Add "InnoDB:" sub-header before grouped InnoDB_* attributes.
|
||||
@@ -414,10 +410,7 @@ sub query_report {
|
||||
}
|
||||
|
||||
# Sort the attributes, removing any hidden attributes.
|
||||
my $attribs = $self->sort_attribs(
|
||||
($args{select} ? $args{select} : $ea->get_attributes()),
|
||||
$ea,
|
||||
);
|
||||
my $attribs = $self->sort_attribs( $ea );
|
||||
|
||||
# Print each worst item: its stats/metrics (sum/min/max/95%/etc.),
|
||||
# Query_time distro chart, tables, EXPLAIN, fingerprint, etc.
|
||||
@@ -584,10 +577,7 @@ sub event_report_values {
|
||||
# will sort and pass the attribs so they're not for every event.
|
||||
my $attribs = $args{attribs};
|
||||
if ( !$attribs ) {
|
||||
$attribs = $self->sort_attribs(
|
||||
($args{select} ? $args{select} : $ea->get_attributes()),
|
||||
$ea
|
||||
);
|
||||
$attribs = $self->sort_attribs( $ea );
|
||||
}
|
||||
|
||||
$vals{attributes} = { map { $_ => [] } qw(num innodb bool string) };
|
||||
@@ -1124,7 +1114,6 @@ sub bool_percents {
|
||||
# Does pretty-printing for lists of strings like users, hosts, db.
|
||||
sub format_string_list {
|
||||
my ( $self, $attrib, $vals, $class_cnt ) = @_;
|
||||
my $show_all = $self->{options}->{show_all};
|
||||
|
||||
# Only class result values have unq. So if unq doesn't exist,
|
||||
# then we've been given global values.
|
||||
@@ -1157,9 +1146,6 @@ sub format_string_list {
|
||||
}
|
||||
my $p = percentage_of($cnt_for->{$str}, $class_cnt);
|
||||
$print_str .= " ($cnt_for->{$str}/$p%)";
|
||||
if ( !$show_all->{$attrib} ) {
|
||||
last if (length $line) + (length $print_str) > LINE_LENGTH - 27;
|
||||
}
|
||||
$line .= "$print_str, ";
|
||||
$i++;
|
||||
}
|
||||
@@ -1174,7 +1160,8 @@ sub format_string_list {
|
||||
}
|
||||
|
||||
sub sort_attribs {
|
||||
my ( $self, $attribs, $ea ) = @_;
|
||||
my ( $self, $ea ) = @_;
|
||||
my $attribs = $ea->get_attributes();
|
||||
return unless $attribs && @$attribs;
|
||||
PTDEBUG && _d("Sorting attribs:", @$attribs);
|
||||
|
||||
|
@@ -1526,11 +1526,14 @@ ok(
|
||||
'New event class has new attrib; default unroll_limit(issue 514)'
|
||||
);
|
||||
|
||||
$ea = new EventAggregator(
|
||||
groupby => 'arg',
|
||||
worst => 'Query_time',
|
||||
unroll_limit => 50,
|
||||
);
|
||||
$ea = do {
|
||||
local $ENV{PT_QUERY_DIGEST_CHECK_ATTRIB_LIMIT} = 50;
|
||||
new EventAggregator(
|
||||
groupby => 'arg',
|
||||
worst => 'Query_time'
|
||||
);
|
||||
};
|
||||
|
||||
parse_file('t/lib/samples/slowlogs/slow030.txt', $p, $ea);
|
||||
ok(
|
||||
!exists $ea->{unrolled_for}->{InnoDB_rec_lock_wait},
|
||||
|
@@ -464,7 +464,7 @@ ok(
|
||||
# #############################################################################
|
||||
|
||||
# This test uses the $ea from the Bool pretty printer test above.
|
||||
my $sorted = $qrf->sort_attribs($ea->get_attributes(), $ea);
|
||||
my $sorted = $qrf->sort_attribs($ea);
|
||||
is_deeply(
|
||||
$sorted,
|
||||
{
|
||||
@@ -511,7 +511,7 @@ foreach my $event (@$events) {
|
||||
}
|
||||
$ea->calculate_statistical_metrics();
|
||||
|
||||
$sorted = $qrf->sort_attribs($ea->get_attributes(), $ea);
|
||||
$sorted = $qrf->sort_attribs($ea);
|
||||
is_deeply(
|
||||
$sorted,
|
||||
{
|
||||
@@ -689,7 +689,7 @@ ok(
|
||||
"t/lib/samples/QueryReportFormatter/report010.txt",
|
||||
cmd_output => 1,
|
||||
),
|
||||
'Truncate one long string'
|
||||
"Don't truncate one long string"
|
||||
);
|
||||
|
||||
$ea->reset_aggregated_data();
|
||||
@@ -721,7 +721,7 @@ ok(
|
||||
"t/lib/samples/QueryReportFormatter/report011.txt",
|
||||
cmd_output => 1,
|
||||
),
|
||||
'Truncate multiple long strings'
|
||||
"Don't truncate multiple long strings"
|
||||
);
|
||||
|
||||
$ea->reset_aggregated_data();
|
||||
@@ -753,7 +753,7 @@ ok(
|
||||
"t/lib/samples/QueryReportFormatter/report012.txt",
|
||||
cmd_output => 1,
|
||||
),
|
||||
'Truncate multiple strings longer than whole line'
|
||||
"Don't truncate multiple strings longer than whole line"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
@@ -881,16 +881,6 @@ ok(
|
||||
"IPs not shortened with more"
|
||||
);
|
||||
|
||||
# Test show_all.
|
||||
@ARGV = qw(--show-all host);
|
||||
$o->get_opts();
|
||||
$qrf = new QueryReportFormatter(
|
||||
OptionParser => $o,
|
||||
QueryRewriter => $qr,
|
||||
QueryParser => $qp,
|
||||
Quoter => $q,
|
||||
ExplainAnalyzer => $ex,
|
||||
);
|
||||
$result = $qrf->event_report(
|
||||
ea => $ea,
|
||||
select => [ qw(Query_time host) ],
|
||||
|
@@ -7,4 +7,4 @@
|
||||
# Count 100 3
|
||||
# Exec time 100 6s 1s 3s 2s 3s 780ms 2s
|
||||
# String:
|
||||
# foo Hi. I'm a... (1/33%), Me too! I'... (1/33%)... 1 more
|
||||
# foo Hi. I'm a... (1/33%), Me too! I'... (1/33%), Number 3 l... (1/33%)
|
||||
|
@@ -5,4 +5,4 @@
|
||||
# Count 100 2
|
||||
# Exec time 100 16s 8s 8s 8s 8s 0 8s
|
||||
# String:
|
||||
# Hosts 123.123.123.456 (1/50%)... 1 more
|
||||
# Hosts 123.123.123.456 (1/50%), 123.123.123.789 (1/50%)
|
||||
|
@@ -5,4 +5,4 @@
|
||||
# Count 100 3
|
||||
# Exec time 100 24s 8s 8s 8s 8s 0 8s
|
||||
# String:
|
||||
# Hosts 123.123.123.456 (1/33%)... 2 more
|
||||
# Hosts 123.123.123.456 (1/33%), 123.123.123.789 (1/33%), 123.123.123.999 (1/33%)
|
||||
|
@@ -1,44 +0,0 @@
|
||||
|
||||
# Query 1: 0 QPS, 0x concurrency, ID 0x7F7D57ACDD8A346E at byte 0 ________
|
||||
# This item is included in the report because it matches --limit.
|
||||
# Scores: V/M = 0.00
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||
# Count 50 1
|
||||
# Exec time 50 2s 2s 2s 2s 2s 0 2s
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us
|
||||
# 100us
|
||||
# 1ms
|
||||
# 10ms
|
||||
# 100ms
|
||||
# 1s ################################################################
|
||||
# 10s+
|
||||
# Tables
|
||||
# SHOW TABLE STATUS FROM `test` LIKE 'n'\G
|
||||
# SHOW CREATE TABLE `test`.`n`\G
|
||||
# EXPLAIN /*!50100 PARTITIONS*/
|
||||
select sleep(2) from n\G
|
||||
|
||||
# Query 2: 0 QPS, 0x concurrency, ID 0x3A99CC42AEDCCFCD at byte 359 ______
|
||||
# This item is included in the report because it matches --limit.
|
||||
# Scores: V/M = 0.00
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||
# Count 50 1
|
||||
# Exec time 50 2s 2s 2s 2s 2s 0 2s
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us
|
||||
# 100us
|
||||
# 1ms
|
||||
# 10ms
|
||||
# 100ms
|
||||
# 1s ################################################################
|
||||
# 10s+
|
||||
# Tables
|
||||
# SHOW TABLE STATUS FROM `test` LIKE 'n'\G
|
||||
# SHOW CREATE TABLE `test`.`n`\G
|
||||
# EXPLAIN /*!50100 PARTITIONS*/
|
||||
select sleep(2) from test.n\G
|
@@ -1,30 +0,0 @@
|
||||
|
||||
# Query 1: 0 QPS, 0x concurrency, ID 0x7CE9953EA3A36141 at byte 417 ______
|
||||
# This item is included in the report because it matches --limit.
|
||||
# Scores: V/M = 0.00
|
||||
# Time range: all events occurred at 2009-12-05 19:55:11
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||
# Count 100 3
|
||||
# Exec time 100 2ms 613us 613us 613us 613us 0 613us
|
||||
# Lock time 99 321us 107us 107us 107us 107us 0 107us
|
||||
# Rows sent 100 690 230 230 230 230 0 230
|
||||
# Rows examine 100 690 230 230 230 230 0 230
|
||||
# Rows affecte 0 0 0 0 0 0 0 0
|
||||
# Rows read 100 690 230 230 230 230 0 230
|
||||
# Query size 100 31 10 11 10.33 10.84 0.47 9.83
|
||||
# String:
|
||||
# Hosts 123.123.123.121 (1/33%)... 2 more
|
||||
# Users chessguest
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us
|
||||
# 100us ################################################################
|
||||
# 1ms
|
||||
# 10ms
|
||||
# 100ms
|
||||
# 1s
|
||||
# 10s+
|
||||
# EXPLAIN /*!50100 PARTITIONS*/
|
||||
select foo
|
||||
\G
|
@@ -72,7 +72,7 @@ SELECT * FROM bar WHERE id=12\G
|
||||
# Rows examine 0 0 0 0 0 0 0 0
|
||||
# Query size 45 140 28 28 28 28 0 28
|
||||
# String:
|
||||
# arg crc 108 (1/20%), 306 (1/20%), 353 (1/20%)... 2 more
|
||||
# arg crc 108 (1/20%), 306 (1/20%), 353 (1/20%), 558 (1/20%), 887 (1/20%)
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us ################################################################
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# Rows examine 0 0 0 0 0 0 0 0
|
||||
# Query size 100 224 28 28 28 28 0 28
|
||||
# String:
|
||||
# InnoDB trxID 101 (1/12%), 102 (1/12%), 103 (1/12%)... 5 more
|
||||
# InnoDB trxID 101 (1/12%), 102 (1/12%), 103 (1/12%), 104 (1/12%), 105 (1/12%), 106 (1/12%), A07 (1/12%), A08 (1/12%)
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us ################################################################
|
||||
|
@@ -56,7 +56,7 @@ select * from d.t where name="adam"\G
|
||||
# Warning coun 0 0 0 0 0 0 0 0
|
||||
# String:
|
||||
# Hosts 127.0.0.1
|
||||
# Statement id 2 (1/20%), 3 (1/20%), 4 (1/20%), 5 (1/20%)... 1 more
|
||||
# Statement id 2 (1/20%), 3 (1/20%), 4 (1/20%), 5 (1/20%), 6 (1/20%)
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us
|
||||
|
@@ -63,14 +63,6 @@ ok(
|
||||
'Timeline for slow002 with distill'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_query_digest::main(@args, $sample.'slow001.txt', qw(--select Query_time)) },
|
||||
"t/pt-query-digest/samples/slow001_select_report.txt"
|
||||
),
|
||||
'Analysis for slow001 --select'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_query_digest::main(@args, $sample.'slow002.txt') },
|
||||
@@ -307,23 +299,13 @@ is(
|
||||
);
|
||||
diag(`rm -rf /tmp/mqd-warnings.txt`);
|
||||
|
||||
# Issue 940
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_query_digest::main(@args, $sample.'slow042.txt',
|
||||
qw(--report-format query_report)) },
|
||||
"t/pt-query-digest/samples/slow042.txt",
|
||||
),
|
||||
'Analysis for slow042'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_query_digest::main(@args, $sample.'slow042.txt',
|
||||
qw(--report-format query_report --show-all host)) },
|
||||
"t/pt-query-digest/samples/slow042-show-all-host.txt",
|
||||
),
|
||||
'Analysis for slow042 with --show-all hosts'
|
||||
'Analysis for slow042 (previously the --show-all test)'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
@@ -389,8 +371,7 @@ ok(
|
||||
no_diff(
|
||||
sub {
|
||||
local $ENV{PT_QUERY_DIGEST_CHECK_ATTRIB_LIMIT} = 5;
|
||||
pt_query_digest::main(@args, $sample.'slow054.txt',
|
||||
qw(--check-attributes-limit 5))
|
||||
pt_query_digest::main(@args, $sample.'slow054.txt')
|
||||
},
|
||||
"t/pt-query-digest/samples/slow054.txt",
|
||||
),
|
||||
|
Reference in New Issue
Block a user