mirror of
https://gitlab.com/depesz/explain.depesz.com.git
synced 2024-11-24 08:42:27 +02:00
Dont use cursor for getting plans
Cursors cause bug in Pg15
This commit is contained in:
parent
23f69af2d8
commit
5492f6a2b8
@ -68,11 +68,12 @@ for my $partno ( 0 .. $#{ $partitions } ) {
|
||||
my $errors = 0;
|
||||
my $interesting = 0;
|
||||
|
||||
my $query = sprintf "select id, plan FROM %s WHERE is_public and NOT is_deleted and NOT is_anonymized and plan ~ 'actual time=[0-9]'", $part;
|
||||
$dbh->do( "DECLARE csr CURSOR FOR $query" );
|
||||
my $prev_id = '';
|
||||
my $query = sprintf "select id, plan FROM %s WHERE is_public and NOT is_deleted and NOT is_anonymized and plan ~ 'actual time=[0-9]' AND id > ? order by ID ASC LIMIT 100", $part;
|
||||
while ( 1 ) {
|
||||
my $rows = $dbh->selectall_arrayref( 'FETCH 100 FROM csr', { 'Slice' => {} } );
|
||||
my $rows = $dbh->selectall_arrayref( $query, { 'Slice' => {} }, $prev_id );
|
||||
last if 0 == scalar @{ $rows };
|
||||
$prev_id = $rows->[ -1 ]->{ 'id' };
|
||||
for my $row ( @{ $rows } ) {
|
||||
$seen++;
|
||||
my $explain;
|
||||
@ -112,6 +113,7 @@ exit;
|
||||
sub output_lines {
|
||||
my ( $id, $plan ) = @_;
|
||||
my $ret = [];
|
||||
my $plan_len = length( $plan->source );
|
||||
for my $node ( $plan->top_node, $plan->top_node->all_recursive_subnodes ) {
|
||||
|
||||
next unless $node->estimated_row_width;
|
||||
@ -120,16 +122,17 @@ sub output_lines {
|
||||
next unless $node->extra_info;
|
||||
|
||||
# At least 3 pages worth of data is returned
|
||||
next unless $node->total_rows * $node->estimated_row_width > 3 * 8192;
|
||||
next unless ( $node->total_rows + $node->total_rows_removed ) * $node->estimated_row_width > 3 * 8192;
|
||||
|
||||
# At least 90% of rows were removed
|
||||
next unless $node->total_rows_removed > 9 * $node->total_rows;
|
||||
next unless $node->total_rows_removed > 2 * $node->total_rows;
|
||||
|
||||
my @filter_lines = grep { /^Filter:/ } @{ $node->extra_info };
|
||||
|
||||
# There are filter expressions
|
||||
next if 0 == scalar @filter_lines;
|
||||
|
||||
push @{ $ret }, map { [ $id, $node->id, $node->type, $node->estimated_row_width, $node->total_rows, $node->total_rows_removed, $_ ] } @filter_lines;
|
||||
push @{ $ret }, map { [ $id, $plan_len, $node->type, $_ ] } @filter_lines;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user