Commit 97ef20de authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

It is more efficient to give MySQL a LIMIT clause

parent e2ac50d8
...@@ -103,14 +103,13 @@ sub _get_rowcount_bound { ...@@ -103,14 +103,13 @@ sub _get_rowcount_bound {
my $inputquery = $self->param_substitute( $self->param('inputquery') ); my $inputquery = $self->param_substitute( $self->param('inputquery') );
warn "Testing at least '$maxrow' rows of the input query: '$inputquery'" if ($self->debug()); warn "Testing at least '$maxrow' rows of the input query: '$inputquery'" if ($self->debug());
$inputquery .= " LIMIT $maxrow" unless $inputquery =~ /LIMIT/i;
my $sth = $self->data_dbc()->prepare($inputquery); my $sth = $self->data_dbc()->prepare($inputquery);
$sth->execute(); $sth->execute();
my $nrow = 0; my $nrow = 0;
while ($nrow < $maxrow) { while (defined $sth->fetchrow_arrayref()) {
my $row = $sth->fetchrow_arrayref();
last unless (defined $row);
$nrow++; $nrow++;
} }
$sth->finish; $sth->finish;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment