electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
9.45k stars 204 forks source link

File Size Growth on API Calls #405

Closed jhje0316 closed 4 weeks ago

jhje0316 commented 1 month ago

I have been testing the insertion and execution of SQL commands with thousands of rows using IndexedDB. I noticed that the file size increases with each SQL execution.

For example, executing the query:

SELECT COUNT(*) FROM orders;

results in a permanent file size increase of approximately 0.3 MB(might vary depending on the size of the inserted data), as observed in Chrome DevTools under Application > Storage > Usage.

I am concerned about this growth because I expect a user to execute thousands of SQL queries within a single database file in my service, and I want to keep the file size as small as possible.

Questions:

  1. Are there any solutions to prevent this increase in file size?
  2. Can anyone provide insights into why this growth is occurring?
jhje0316 commented 4 weeks ago

I just wanted to follow up on my previous issue. After doing a bit more testing, I realized that I was mistakenly creating a new PGlite instance every time I called the API to execute SQL commands.

I’ll go ahead and close this issue since it's resolved.