diff --git a/lib/utils/db/query.pm b/lib/utils/db/query.pm
index bfe00fc404cb5abd55caaf2f32e5cf057946c106..633d7a892bddfb72e0f3256cafe53c19fec255c0 100644
--- a/lib/utils/db/query.pm
+++ b/lib/utils/db/query.pm
@@ -70,9 +70,15 @@ sub _get_next {
     my $result = $self->_sth->{$chan}->fetch();
     return $result if ($result);
 
-    # there is no more data to fetch
+    # we come here only if there is no more data to fetch
+
+    # we take care of the db
     $self->_sth->{$chan} = undef;
     $self->_get_dbh($chan)->commit();
+
+    # we remove the query
+    $self->_queries->{$chan} = undef;
+
     return undef;
 }