Repository navigation
Replies: 2 comments
|
With version 0.4.x we've opened the possibility to pass arbitrary parameters to PGlite that will be sent further to Postgres when starting. See |
|
As tdrz mentioned, import { PGlite } from "@electric-sql/pglite";
const db = await PGlite.create({
dataDir: "idb://myapp",
startParams: [
...PGlite.defaultStartParams,
"-c", "max_wal_size=64MB",
"-c", "min_wal_size=16MB",
"-c", "wal_level=minimal",
"-c", "checkpoint_timeout=30s",
"-c", "shared_buffers=32MB",
"-c", "work_mem=4MB",
],
});The key params for your case:
For Tauri v2 specifically — use import { appDataDir } from "@tauri-apps/api/path";
const dataDir = typeof window.__TAURI__ !== "undefined"
? await appDataDir() + "/pglite"
: "idb://myapp";IndexedDB has higher overhead per write than native FS, so the WAL tuning matters more in the browser. On native (Tauri desktop), filesystem IO is fast enough that WAL size is less of a concern, but keeping One thing to watch: |
Uh oh!
There was an error while loading. Please reload this page.
I'm running PGLite in a desktop app in Tauri. The app is also supposed to be working in the browser (at least partially). I'm looking for ways to optimize RAM usage as the DB is supposed to handle 100k+ rows. My main bottleneck seems to be the WAL which can grow up to 1 GB large which is just unnecessary for my use-case. Is there a way to control it? Any other ways to optimize RAM usage? What's the optimal FS to use with Tauri v2?
All reactions