about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-05 22:59:31 +0000
committerEric Wong <e@80x24.org>2020-12-07 07:31:00 +0000
commita0c41f3d5e9b40bfbb066fa7f0e2e530818ccc0a (patch)
treeeb81df04cd4b166167dd3375f599ee428ec512ae /lib/PublicInbox
parent4b551c884a648b45ec6b5465efd9fb67f85f0055 (diff)
downloadpublic-inbox-a0c41f3d5e9b40bfbb066fa7f0e2e530818ccc0a.tar.gz
INTEGER PRIMARY KEY can be an alias for ROWID in SQLite and is
already unique, so there's no need for a separate UNIQUE(num)
index.

With a smallish ~3K, freshly indexed v2 inbox, this results in a
~40K space savings, reducing over.sqlite3 from 1.375M to 1.335M
(post-VACUUM).

This only affects newly-indexed inboxes; existing DBs will
require manual intervention to take advantage of space savings.

Link: https://www.sqlite.org/rowidtable.html
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/OverIdx.pm5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 88daa64f..635aa314 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -389,13 +389,12 @@ sub create_tables {
 
         $dbh->do(<<'');
 CREATE TABLE IF NOT EXISTS over (
-        num INTEGER NOT NULL, /* NNTP article number == IMAP UID */
+        num INTEGER PRIMARY KEY NOT NULL, /* NNTP article number == IMAP UID */
         tid INTEGER NOT NULL, /* THREADID (IMAP REFERENCES threading, JMAP) */
         sid INTEGER, /* Subject ID (IMAP ORDEREDSUBJECT "threading") */
         ts INTEGER, /* IMAP INTERNALDATE (Received: header, git commit time) */
         ds INTEGER, /* RFC-2822 sent Date: header, git author time */
-        ddd VARBINARY, /* doc-data-deflated (->to_doc_data, ->load_from_data) */
-        UNIQUE (num)
+        ddd VARBINARY /* doc-data-deflated (->to_doc_data, ->load_from_data) */
 )
 
         $dbh->do('CREATE INDEX IF NOT EXISTS idx_tid ON over (tid)');