From: Sven Schöling Date: Thu, 21 Apr 2016 17:26:48 +0000 (+0200) Subject: DB-Upgrade: Queries nicht in der Schleife preparen X-Git-Tag: release-3.4.1~181 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0630567f600b194c1e9c3e97eb8e117b73f88402;p=kivitendo-erp.git DB-Upgrade: Queries nicht in der Schleife preparen Datenbank mit 100k invoice Einträgen braucht Jahre sonst. --- diff --git a/sql/Pg-upgrade2/invoice_positions.pl b/sql/Pg-upgrade2/invoice_positions.pl index f8bc9112f..d92daca6e 100644 --- a/sql/Pg-upgrade2/invoice_positions.pl +++ b/sql/Pg-upgrade2/invoice_positions.pl @@ -17,8 +17,10 @@ sub run { $query = qq|SELECT * FROM invoice ORDER BY trans_id, id|; + my $query2 = qq|UPDATE invoice SET position = ? WHERE id = ?|; my $sth = $self->dbh->prepare($query); + my $sth2 = $self->dbh->prepare($query2); $sth->execute || $::form->dberror($query); # set new position field in order of ids, starting by one for each invoice @@ -32,10 +34,10 @@ sub run { } $last_invoice_id = $ref->{trans_id}; - $query = qq|UPDATE invoice SET position = ? WHERE id = ?|; - $self->db_query($query, bind => [ $position, $ref->{id} ]); + $sth2->execute($position, $ref->{id}); } $sth->finish; + $sth2->finish; $query = qq|ALTER TABLE invoice ALTER COLUMN position SET NOT NULL|; $self->db_query($query); diff --git a/sql/Pg-upgrade2/orderitems_delivery_order_items_positions.pl b/sql/Pg-upgrade2/orderitems_delivery_order_items_positions.pl index cda92006c..712ce835e 100644 --- a/sql/Pg-upgrade2/orderitems_delivery_order_items_positions.pl +++ b/sql/Pg-upgrade2/orderitems_delivery_order_items_positions.pl @@ -25,8 +25,10 @@ sub run { my $order_id_col = $order_id_cols{ $table }; $query = qq|SELECT * FROM $table ORDER BY $order_id_col, id|; + my $query2 = qq|UPDATE $table SET position = ? WHERE id = ?|; my $sth = $self->dbh->prepare($query); + my $sth2 = $self->dbh->prepare($query2); $sth->execute || $::form->dberror($query); # set new position field in order of ids, starting by one for each order @@ -40,10 +42,10 @@ sub run { } $last_order_id = $ref->{ $order_id_col }; - $query = qq|UPDATE $table SET position = ? WHERE id = ?|; - $self->db_query($query, bind => [ $position, $ref->{id} ]); + $sth2->execute($position, $ref->{id}); } $sth->finish; + $sth2->finish; $query = qq|ALTER TABLE $table ALTER COLUMN position SET NOT NULL|;