Skip to content

Commit 522aeba

Browse files
committed
improve db performance
1 parent 1ff8ed7 commit 522aeba

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

db.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ type DBHandler struct {
1717
}
1818

1919
func (h *DBHandler) initializeDB() error {
20+
21+
pragmas := []string{
22+
"PRAGMA synchronous = OFF", // Disable synchronous writes for faster performance
23+
"PRAGMA journal_mode = WAL", // Enable Write-Ahead Logging for better concurrency
24+
"PRAGMA cache_size = -10000", // Increase cache size to 10,000 pages (adjust as needed)
25+
"PRAGMA mmap_size = 268435456", // Enable memory-mapped I/O with 256 MB
26+
"PRAGMA temp_store = MEMORY", // Store temporary tables and indices in memory
27+
"PRAGMA locking_mode = EXCLUSIVE", // Use exclusive locking mode (since no concurrent writes)
28+
}
29+
30+
for _, pragma := range pragmas {
31+
if _, err := h.db.Exec(pragma); err != nil {
32+
return fmt.Errorf("error executing PRAGMA %s: %v", pragma, err)
33+
}
34+
}
35+
2036
queries := []string{
2137
`CREATE TABLE IF NOT EXISTS articles (
2238
id INTEGER PRIMARY KEY,

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"os"
1111
)
1212

13-
const Version = "0.0.34"
13+
const Version = "0.0.35"
1414

1515
type Config struct {
1616
importPath string //https://dumps.wikimedia.org/other/enterprise_html/runs/...

0 commit comments

Comments
 (0)