Skip to content

Commit 57df479

Browse files
committed
Don't use WAL mode & extend schema with metadata
The WAL mode is persistent and only works with sqlite >= 3.7, which isn't great for our distribution use case. It does help performance a bit with synchronous=NORMAL by only requiring an fsync on checkpoint (every 1000 pages or so), but we might as well set synchronous=OFF for dumps. This patch also adds revision metadata in the schema, but does not actually fill this yet. We'll need to fetch this information separately, or extract (some of) it from the HTML head. The former will work for other formats like wikitext or JSON as well, so should be preferable.
1 parent 2934d96 commit 57df479

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

sqlitestore.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@ var pragmas = [
77
'PRAGMA main.page_size = 4096',
88
'PRAGMA main.cache_size=10000',
99
'PRAGMA main.locking_mode=EXCLUSIVE',
10-
'PRAGMA main.synchronous=NORMAL',
11-
'PRAGMA main.journal_mode=WAL',
12-
'PRAGMA main.cache_size=5000'
10+
'PRAGMA main.synchronous=OFF', // more dangerous, but fast
11+
//'PRAGMA main.synchronous=NORMAL',
12+
//'PRAGMA main.journal_mode=WAL', // WAL is annoying for distributed files
1313
];
1414
var createTableQuery = 'CREATE TABLE IF NOT EXISTS data('
15-
+ 'title TEXT, revision INTEGER, body BLOB, namespace INTEGER'
16-
+ ', PRIMARY KEY(title ASC, revision DESC)'
15+
+ 'title TEXT,'
16+
+ 'revision INTEGER,'
17+
+ 'body BLOB,'
18+
+ 'bigendian_v1_uuid text,' // etag header, reordered
19+
// Metadata that we'll have to extract from the revision or HTML head.
20+
+ 'page_id INTEGER,' // missing from revision metadata
21+
+ 'namespace INTEGER,'
22+
+ 'timestamp TEXT,' // missing from revision metadata
23+
+ 'comment TEXT,'
24+
+ 'user_name TEXT,'
25+
+ 'user_id INTEGER,'
26+
+ 'PRIMARY KEY(title ASC, revision DESC)'
1727
+ ')';
1828
var checkQuery = 'select revision from data where title = ? and revision = ? limit 1';
1929
var purgeTitleQuery = 'delete from data where title = ?';

0 commit comments

Comments
 (0)