Merged fix-1160918-restore-show-all

This commit is contained in:
Brian Fraser
2013-04-16 17:48:05 -03:00
10 changed files with 47 additions and 10 deletions

View File

@@ -6525,6 +6525,12 @@ has event_headers => (
default => sub { [qw(pct total min max avg 95% stddev median)] }, default => sub { [qw(pct total min max avg 95% stddev median)] },
); );
has show_all => (
is => 'ro',
isa => 'HashRef',
default => sub { {} },
);
has ReportFormatter => ( has ReportFormatter => (
is => 'ro', is => 'ro',
isa => 'ReportFormatter', isa => 'ReportFormatter',
@@ -7409,6 +7415,8 @@ sub format_string_list {
return ($vals->{cnt}); return ($vals->{cnt});
} }
my $show_all = $self->show_all();
my $cnt_for = $vals->{unq}; my $cnt_for = $vals->{unq};
if ( 1 == keys %$cnt_for ) { if ( 1 == keys %$cnt_for ) {
my ($str) = keys %$cnt_for; my ($str) = keys %$cnt_for;
@@ -7433,6 +7441,9 @@ sub format_string_list {
} }
my $p = percentage_of($cnt_for->{$str}, $class_cnt); my $p = percentage_of($cnt_for->{$str}, $class_cnt);
$print_str .= " ($cnt_for->{$str}/$p%)"; $print_str .= " ($cnt_for->{$str}/$p%)";
if ( !$show_all->{$attrib} ) {
last if (length $line) + (length $print_str) > LINE_LENGTH - 27;
}
$line .= "$print_str, "; $line .= "$print_str, ";
$i++; $i++;
} }
@@ -13764,6 +13775,8 @@ sub print_reports {
my @groupby = @{$args{groupby}}; my @groupby = @{$args{groupby}};
my @orderby = @{$args{orderby}}; my @orderby = @{$args{orderby}};
my $show_all = $o->get('show-all');
for my $i ( 0..$#groupby ) { for my $i ( 0..$#groupby ) {
if ( $o->get('report') || $qv || $qh ) { if ( $o->get('report') || $qv || $qh ) {
$eas->[$i]->calculate_statistical_metrics(); $eas->[$i]->calculate_statistical_metrics();
@@ -13814,6 +13827,7 @@ sub print_reports {
OptionParser => $args{OptionParser}, OptionParser => $args{OptionParser},
QueryParser => $args{QueryParser}, QueryParser => $args{QueryParser},
Quoter => $args{Quoter}, Quoter => $args{Quoter},
show_all => $show_all,
); );
$qrf->print_reports( $qrf->print_reports(
@@ -15517,6 +15531,18 @@ example, specifying C<--set-vars wait_timeout=500> overrides the defaultvalue of
The tool prints a warning and continues if a variable cannot be set. The tool prints a warning and continues if a variable cannot be set.
=item --show-all
type: Hash
Show all values for these attributes.
By default pt-query-digest only shows as many of an attribute's value that
fit on a single line. This option allows you to specify attributes for which
all values will be shown (line width is ignored). This only works for
attributes with string values like user, host, db, etc. Multiple attributes
can be specified, comma-separated.
=item --since =item --since
type: string type: string

View File

@@ -84,6 +84,12 @@ has event_headers => (
default => sub { [qw(pct total min max avg 95% stddev median)] }, default => sub { [qw(pct total min max avg 95% stddev median)] },
); );
has show_all => (
is => 'ro',
isa => 'HashRef',
default => sub { {} },
);
has ReportFormatter => ( has ReportFormatter => (
is => 'ro', is => 'ro',
isa => 'ReportFormatter', isa => 'ReportFormatter',
@@ -1121,6 +1127,8 @@ sub format_string_list {
return ($vals->{cnt}); return ($vals->{cnt});
} }
my $show_all = $self->show_all();
my $cnt_for = $vals->{unq}; my $cnt_for = $vals->{unq};
if ( 1 == keys %$cnt_for ) { if ( 1 == keys %$cnt_for ) {
my ($str) = keys %$cnt_for; my ($str) = keys %$cnt_for;
@@ -1146,6 +1154,9 @@ sub format_string_list {
} }
my $p = percentage_of($cnt_for->{$str}, $class_cnt); my $p = percentage_of($cnt_for->{$str}, $class_cnt);
$print_str .= " ($cnt_for->{$str}/$p%)"; $print_str .= " ($cnt_for->{$str}/$p%)";
if ( !$show_all->{$attrib} ) {
last if (length $line) + (length $print_str) > LINE_LENGTH - 27;
}
$line .= "$print_str, "; $line .= "$print_str, ";
$i++; $i++;
} }

View File

@@ -7,4 +7,4 @@
# Count 100 3 # Count 100 3
# Exec time 100 6s 1s 3s 2s 3s 780ms 2s # Exec time 100 6s 1s 3s 2s 3s 780ms 2s
# String: # String:
# foo Hi. I'm a... (1/33%), Me too! I'... (1/33%), Number 3 l... (1/33%) # foo Hi. I'm a... (1/33%), Me too! I'... (1/33%)... 1 more

View File

@@ -5,4 +5,4 @@
# Count 100 2 # Count 100 2
# Exec time 100 16s 8s 8s 8s 8s 0 8s # Exec time 100 16s 8s 8s 8s 8s 0 8s
# String: # String:
# Hosts 123.123.123.456 (1/50%), 123.123.123.789 (1/50%) # Hosts 123.123.123.456 (1/50%)... 1 more

View File

@@ -5,4 +5,4 @@
# Count 100 3 # Count 100 3
# Exec time 100 24s 8s 8s 8s 8s 0 8s # Exec time 100 24s 8s 8s 8s 8s 0 8s
# String: # String:
# Hosts 123.123.123.456 (1/33%), 123.123.123.789 (1/33%), 123.123.123.999 (1/33%) # Hosts 123.123.123.456 (1/33%)... 2 more

View File

@@ -5,4 +5,4 @@
# Count 100 3 # Count 100 3
# Exec time 100 24s 8s 8s 8s 8s 0 8s # Exec time 100 24s 8s 8s 8s 8s 0 8s
# String: # String:
# Hosts 123.123.123.456 (1/33%), 123.123.123.789 (1/33%), 123.123.123.999 (1/33%) # Hosts 123.123.123.456 (1/33%)... 2 more

View File

@@ -14,7 +14,7 @@
# Rows read 100 690 230 230 230 230 0 230 # Rows read 100 690 230 230 230 230 0 230
# Query size 100 31 10 11 10.33 10.84 0.47 9.83 # Query size 100 31 10 11 10.33 10.84 0.47 9.83
# String: # String:
# Hosts 123.123.123.121 (1/33%), 123.123.123.122 (1/33%), 123.123.123.123 (1/33%) # Hosts 123.123.123.121 (1/33%)... 2 more
# Users chessguest # Users chessguest
# Query_time distribution # Query_time distribution
# 1us # 1us

View File

@@ -72,7 +72,7 @@ SELECT * FROM bar WHERE id=12\G
# Rows examine 0 0 0 0 0 0 0 0 # Rows examine 0 0 0 0 0 0 0 0
# Query size 45 140 28 28 28 28 0 28 # Query size 45 140 28 28 28 28 0 28
# String: # String:
# arg crc 108 (1/20%), 306 (1/20%), 353 (1/20%), 558 (1/20%), 887 (1/20%) # arg crc 108 (1/20%), 306 (1/20%), 353 (1/20%)... 2 more
# Query_time distribution # Query_time distribution
# 1us # 1us
# 10us ################################################################ # 10us ################################################################

View File

@@ -12,7 +12,7 @@
# Rows examine 0 0 0 0 0 0 0 0 # Rows examine 0 0 0 0 0 0 0 0
# Query size 100 224 28 28 28 28 0 28 # Query size 100 224 28 28 28 28 0 28
# String: # String:
# 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%) # InnoDB trxID 101 (1/12%), 102 (1/12%), 103 (1/12%)... 5 more
# Query_time distribution # Query_time distribution
# 1us # 1us
# 10us ################################################################ # 10us ################################################################

View File

@@ -56,7 +56,7 @@ select * from d.t where name="adam"\G
# Warning coun 0 0 0 0 0 0 0 0 # Warning coun 0 0 0 0 0 0 0 0
# String: # String:
# Hosts 127.0.0.1 # Hosts 127.0.0.1
# Statement id 2 (1/20%), 3 (1/20%), 4 (1/20%), 5 (1/20%), 6 (1/20%) # Statement id 2 (1/20%), 3 (1/20%), 4 (1/20%), 5 (1/20%)... 1 more
# Query_time distribution # Query_time distribution
# 1us # 1us
# 10us # 10us