]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/OverIdx.pm
search: index and allow searching by date-time
[public-inbox.git] / lib / PublicInbox / OverIdx.pm
index 0e43aabc044f61d0f16153b70f554cbc11159fc9..28e4aa9c9b3f83865d8e8c19e23d112dbd8edf40 100644 (file)
@@ -14,21 +14,12 @@ use DBI qw(:sql_types); # SQL_BLOB
 sub dbh_new {
        my ($self) = @_;
        my $dbh = $self->SUPER::dbh_new;
-       $dbh->do('PRAGMA synchronous = OFF'); # commit_fsync instead
        $dbh->do('PRAGMA journal_mode = TRUNCATE');
        $dbh->do('PRAGMA cache_size = 80000');
        create_tables($dbh);
        $dbh;
 }
 
-sub commit_fsync {
-       my $fn = $_[0]->{filename};
-       if (open my $fh, '+<', $fn) {
-               $fh->sync;
-               close $fh;
-       }
-}
-
 sub get_counter ($$) {
        my ($dbh, $key) = @_;
        my $sth = $dbh->prepare_cached(<<'', undef, 1);
@@ -211,7 +202,7 @@ sub link_refs {
 
 sub add_over {
        my ($self, $values) = @_;
-       my ($ts, $num, $mids, $refs, $xpath, $ddd) = @$values;
+       my ($ts, $ds, $num, $mids, $refs, $xpath, $ddd) = @$values;
        my $old_tid;
        my $vivified = 0;
 
@@ -241,11 +232,11 @@ sub add_over {
        my $sid = $self->sid($xpath);
        my $dbh = $self->{dbh};
        my $sth = $dbh->prepare_cached(<<'');
-INSERT INTO over (num, tid, sid, ts, ddd)
-VALUES (?,?,?,?,?)
+INSERT INTO over (num, tid, sid, ts, ds, ddd)
+VALUES (?,?,?,?,?,?)
 
        my $n = 0;
-       my @v = ($num, $tid, $sid, $ts);
+       my @v = ($num, $tid, $sid, $ts, $ds);
        foreach (@v) { $sth->bind_param(++$n, $_) }
        $sth->bind_param(++$n, $ddd, SQL_BLOB);
        $sth->execute;
@@ -283,6 +274,7 @@ CREATE TABLE IF NOT EXISTS over (
        tid INTEGER NOT NULL,
        sid INTEGER,
        ts INTEGER,
+       ds INTEGER,
        ddd VARBINARY, /* doc-data-deflated */
        UNIQUE (num)
 )
@@ -290,6 +282,7 @@ CREATE TABLE IF NOT EXISTS over (
        $dbh->do('CREATE INDEX IF NOT EXISTS idx_tid ON over (tid)');
        $dbh->do('CREATE INDEX IF NOT EXISTS idx_sid ON over (sid)');
        $dbh->do('CREATE INDEX IF NOT EXISTS idx_ts ON over (ts)');
+       $dbh->do('CREATE INDEX IF NOT EXISTS idx_ds ON over (ds)');
 
        $dbh->do(<<'');
 CREATE TABLE IF NOT EXISTS counter (