As recommended by SQLite documentation[1]:
To achieve the best long-term query performance without the need
to do a detailed engineering analysis of the application schema
and SQL, it is recommended that applications run "PRAGMA optimize"
(with no arguments) just before closing each database connection.
Hopefully that works for our use cases and can make things
faster for us.
[1] https://www.sqlite.org/pragma.html#pragma_optimize
sub lms_pause {
my ($self) = @_;
$self->{fmap} = {};
sub lms_pause {
my ($self) = @_;
$self->{fmap} = {};
+ my $dbh = delete $self->{dbh};
+ $dbh->do('PRAGMA optimize') if $dbh;
my $m = $err ? 'rollback' : 'commit';
eval { $mm->{dbh}->$m };
$err .= "msgmap $m: $@\n" if $@;
my $m = $err ? 'rollback' : 'commit';
eval { $mm->{dbh}->$m };
$err .= "msgmap $m: $@\n" if $@;
+ eval { $mm->{dbh}->do('PRAGMA optimize') };
+ $err .= "msgmap optimize: $@\n" if $@;
+ if ($self->{oidx} && $self->{oidx}->{dbh}) {
+ if ($err) {
+ eval { $self->{oidx}->rollback_lazy };
+ $err .= "overview rollback: $@\n" if $@;
+ }
+ eval { $self->{oidx}->{dbh}->do('PRAGMA optimize') };
+ $err .= "overview optimize: $@\n" if $@;
+ }
+
my $shards = delete $self->{idx_shards};
if ($shards) {
for (@$shards) {
my $shards = delete $self->{idx_shards};
if ($shards) {
for (@$shards) {