diff options
author | Eric Wong <e@80x24.org> | 2021-10-11 08:06:16 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-10-12 03:40:35 +0000 |
commit | 4c6d7f06985840068340f33eef81dcf7eb8209e0 (patch) | |
tree | c118e95bdabb77fdad5611cbb978fe2219768c1a /lib/PublicInbox/V2Writable.pm | |
parent | c4a4e9809ddd10f2094e1b088728101ace89297f (diff) | |
download | public-inbox-4c6d7f06985840068340f33eef81dcf7eb8209e0.tar.gz |
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
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r-- | lib/PublicInbox/V2Writable.pm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index fcd7ffe2..d04cdda6 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -622,7 +622,18 @@ sub done { 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) { |