-
|
While working through some performance testing, I realized that I was not able to get PRAMA mmap_size assigned either from a URI DSN or from a direct query. Does go-sqlite3 support this pragma? I created the following test program to show what I am doing and the results that I am seeing. package main
import (
"database/sql"
"fmt"
"log"
"os"
_ "github.com/ncruces/go-sqlite3/driver"
_ "github.com/ncruces/go-sqlite3/embed"
)
func main() {
// Test 1: mmap_size in URI DSN
testDSNPragma()
// Test 2: mmap_size set via SQL PRAGMA
testSQLPragma()
}
func testDSNPragma() {
dbPath := "test_dsn.db"
os.Remove(dbPath)
defer os.Remove(dbPath)
dsn := fmt.Sprintf("file:%s?mmap_size=268435456", dbPath)
db, err := sql.Open("sqlite3", dsn)
if err != nil {
log.Fatalf("Failed to open DB with DSN: %v", err)
}
defer db.Close()
var mmapSize int64
err = db.QueryRow("PRAGMA mmap_size").Scan(&mmapSize)
if err != nil {
log.Fatalf("Failed to query mmap_size: %v", err)
}
fmt.Printf("DSN Pragma Test - mmap_size: %d\n", mmapSize)
switch mmapSize {
case 268435456:
fmt.Println(" Result: SUCCESS (value matches DSN setting)")
case 0:
fmt.Println(" Result: FAILED (mmap_size not set via DSN)")
default:
fmt.Println(" Result: PARTIAL (value set but different)")
}
}
func testSQLPragma() {
dbPath := "test_sql.db"
os.Remove(dbPath)
defer os.Remove(dbPath)
dsn := fmt.Sprintf("file:%s", dbPath)
db, err := sql.Open("sqlite3", dsn)
if err != nil {
log.Fatalf("Failed to open DB: %v", err)
}
defer db.Close()
_, err = db.Exec("PRAGMA mmap_size = 268435456")
if err != nil {
log.Fatalf("Failed to set mmap_size via PRAGMA: %v", err)
}
var mmapSize int64
err = db.QueryRow("PRAGMA mmap_size").Scan(&mmapSize)
if err != nil {
log.Fatalf("Failed to query mmap_size: %v", err)
}
fmt.Printf("\nSQL Pragma Test - mmap_size: %d\n", mmapSize)
switch mmapSize {
case 268435456:
fmt.Println(" Result: SUCCESS (value matches PRAGMA setting)")
case 0:
fmt.Println(" Result: FAILED (mmap_size not set via PRAGMA)")
default:
fmt.Println(" Result: PARTIAL (value set but different)")
}
}The resulting output is: sqlite-dbconnpool on 🍣 main [📝 🛤️ ] via 🐹 v1.26.0 via 14GiB/24GiB
[11:57:58] ➜ go run ./cmd/testNcrucesMmapSize/.
DSN Pragma Test - mmap_size: 0
Result: FAILED (mmap_size not set via DSN)
SQL Pragma Test - mmap_size: 0
Result: FAILED (mmap_size not set via PRAGMA)I have searched the documentation, discussions, wiki and issues and not found anything. I noticed a couple of test cases that contain Thanks in advance, lbe |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
No, Given the way Wasm sandbox works, and how much memory is available to it, it's hard to see a way to support it that actually improves performance. |
Beta Was this translation helpful? Give feedback.
No,
SQLITE_MAX_MMAP_SIZEis set to zero.Given the way Wasm sandbox works, and how much memory is available to it, it's hard to see a way to support it that actually improves performance.