mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 09:40:38 +00:00
pq: Remove --for-explain, make it always show the extra info
This commit is contained in:
@@ -6555,14 +6555,11 @@ sub query_report {
|
|||||||
my ($default_db) = $sample->{db} ? $sample->{db}
|
my ($default_db) = $sample->{db} ? $sample->{db}
|
||||||
: $stats->{db}->{unq} ? keys %{$stats->{db}->{unq}}
|
: $stats->{db}->{unq} ? keys %{$stats->{db}->{unq}}
|
||||||
: undef;
|
: undef;
|
||||||
my @tables;
|
my @tables = $self->{QueryParser}->extract_tables(
|
||||||
if ( $o->get('for-explain') ) {
|
|
||||||
@tables = $self->{QueryParser}->extract_tables(
|
|
||||||
query => $samp_query,
|
query => $samp_query,
|
||||||
default_db => $default_db,
|
default_db => $default_db,
|
||||||
Quoter => $self->{Quoter},
|
Quoter => $self->{Quoter},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
$report .= "\n" if $rank > 1; # space between each event report
|
$report .= "\n" if $rank > 1; # space between each event report
|
||||||
$report .= $self->event_report(
|
$report .= $self->event_report(
|
||||||
@@ -6599,8 +6596,7 @@ sub query_report {
|
|||||||
|
|
||||||
PTDEBUG && _d("Fingerprint\n# $item\n");
|
PTDEBUG && _d("Fingerprint\n# $item\n");
|
||||||
|
|
||||||
$report .= $self->tables_report(@tables)
|
$report .= $self->tables_report(@tables);
|
||||||
if $o->get('for-explain');
|
|
||||||
|
|
||||||
if ( $samp_query && ($args{variations} && @{$args{variations}}) ) {
|
if ( $samp_query && ($args{variations} && @{$args{variations}}) ) {
|
||||||
my $crc = crc32($samp_query);
|
my $crc = crc32($samp_query);
|
||||||
@@ -6624,8 +6620,7 @@ sub query_report {
|
|||||||
else {
|
else {
|
||||||
$report .= "$samp_query${mark}\n";
|
$report .= "$samp_query${mark}\n";
|
||||||
my $converted = $qr->convert_to_select($samp_query);
|
my $converted = $qr->convert_to_select($samp_query);
|
||||||
if ( $o->get('for-explain')
|
if ( $converted
|
||||||
&& $converted
|
|
||||||
&& $converted =~ m/^[\(\s]*select/i ) {
|
&& $converted =~ m/^[\(\s]*select/i ) {
|
||||||
$report .= "# Converted for EXPLAIN\n# EXPLAIN /*!50100 PARTITIONS*/\n$converted${mark}\n";
|
$report .= "# Converted for EXPLAIN\n# EXPLAIN /*!50100 PARTITIONS*/\n$converted${mark}\n";
|
||||||
}
|
}
|
||||||
@@ -15259,17 +15254,6 @@ check both.
|
|||||||
Since L<"--filter"> allows you to alter C<$event>, you can use it to do other
|
Since L<"--filter"> allows you to alter C<$event>, you can use it to do other
|
||||||
things, like create new attributes. See L<"ATTRIBUTES"> for an example.
|
things, like create new attributes. See L<"ATTRIBUTES"> for an example.
|
||||||
|
|
||||||
=item --[no]for-explain
|
|
||||||
|
|
||||||
default: yes
|
|
||||||
|
|
||||||
Print extra information to make analysis easy.
|
|
||||||
|
|
||||||
This option adds code snippets to make it easy to run SHOW CREATE TABLE and SHOW
|
|
||||||
TABLE STATUS for the query's tables. It also rewrites non-SELECT queries into a
|
|
||||||
SELECT that might be helpful for determining the non-SELECT statement's index
|
|
||||||
usage.
|
|
||||||
|
|
||||||
=item --group-by
|
=item --group-by
|
||||||
|
|
||||||
type: Array; default: fingerprint
|
type: Array; default: fingerprint
|
||||||
|
@@ -364,20 +364,14 @@ sub query_report {
|
|||||||
next ITEM if $review_vals->{reviewed_by} && !$o->get('report-all');
|
next ITEM if $review_vals->{reviewed_by} && !$o->get('report-all');
|
||||||
}
|
}
|
||||||
|
|
||||||
# ###############################################################
|
|
||||||
# Get tables for --for-explain.
|
|
||||||
# ###############################################################
|
|
||||||
my ($default_db) = $sample->{db} ? $sample->{db}
|
my ($default_db) = $sample->{db} ? $sample->{db}
|
||||||
: $stats->{db}->{unq} ? keys %{$stats->{db}->{unq}}
|
: $stats->{db}->{unq} ? keys %{$stats->{db}->{unq}}
|
||||||
: undef;
|
: undef;
|
||||||
my @tables;
|
my @tables = $self->{QueryParser}->extract_tables(
|
||||||
if ( $o->get('for-explain') ) {
|
|
||||||
@tables = $self->{QueryParser}->extract_tables(
|
|
||||||
query => $samp_query,
|
query => $samp_query,
|
||||||
default_db => $default_db,
|
default_db => $default_db,
|
||||||
Quoter => $self->{Quoter},
|
Quoter => $self->{Quoter},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
# ###############################################################
|
# ###############################################################
|
||||||
# Print the standard query analysis report.
|
# Print the standard query analysis report.
|
||||||
@@ -419,12 +413,10 @@ sub query_report {
|
|||||||
if $o->get('shorten');
|
if $o->get('shorten');
|
||||||
|
|
||||||
# Print query fingerprint.
|
# Print query fingerprint.
|
||||||
$report .= "# Fingerprint\n# $item\n"
|
PTDEBUG && _d("Fingerprint\n# $item\n");
|
||||||
if $o->get('fingerprints');
|
|
||||||
|
|
||||||
# Print tables used by query.
|
# Print tables used by query.
|
||||||
$report .= $self->tables_report(@tables)
|
$report .= $self->tables_report(@tables);
|
||||||
if $o->get('for-explain');
|
|
||||||
|
|
||||||
# Print sample (worst) query's CRC % 1_000. We mod 1_000 because
|
# Print sample (worst) query's CRC % 1_000. We mod 1_000 because
|
||||||
# that's actually the value stored in the ea, not the full checksum.
|
# that's actually the value stored in the ea, not the full checksum.
|
||||||
@@ -453,8 +445,7 @@ sub query_report {
|
|||||||
else {
|
else {
|
||||||
$report .= "$samp_query${mark}\n";
|
$report .= "$samp_query${mark}\n";
|
||||||
my $converted = $qr->convert_to_select($samp_query);
|
my $converted = $qr->convert_to_select($samp_query);
|
||||||
if ( $o->get('for-explain')
|
if ( $converted
|
||||||
&& $converted
|
|
||||||
&& $converted =~ m/^[\(\s]*select/i ) {
|
&& $converted =~ m/^[\(\s]*select/i ) {
|
||||||
# It converted OK to a SELECT
|
# It converted OK to a SELECT
|
||||||
$report .= "# Converted for EXPLAIN\n# EXPLAIN /*!50100 PARTITIONS*/\n$converted${mark}\n";
|
$report .= "# Converted for EXPLAIN\n# EXPLAIN /*!50100 PARTITIONS*/\n$converted${mark}\n";
|
||||||
|
Reference in New Issue
Block a user