←back to thread

353 points HunOL | 7 comments | | HN request time: 0.016s | source | bottom
1. Leherenn ◴[] No.45782370[source]
A bit off topic, but there seems to be quite a few SQLite experts here.

We're having troubles with memory usage when using SQLite in-memory DBs with "a lot" of inserts and deletes. Like maybe inserting up to a 100k rows in 5 minutes, deleting them all after 5 minutes, and doing this for days on end. We see memory usage slowly creeping up over hours/days when doing that.

Any settings that would help with that? It's particularly bad on macOS, we've had instances where we reached 1GB of memory usage according to Activity Monitor after a week or so.

replies(4): >>45782392 #>>45782400 #>>45783445 #>>45783464 #
2. asa400 ◴[] No.45782392[source]
Are you running vacuums at all? auto_vacuum enabled at all?

https://sqlite.org/lang_vacuum.html

replies(1): >>45782475 #
3. kachapopopow ◴[] No.45782400[source]
sounds like normal behavior of adjusting buffers to better fit the usecase, not sure if it applies to sqlite or if sqlite even implements dynamic buffers.
4. porridgeraisin ◴[] No.45782475[source]
In memory DBs don't have anything to vacuum.

However... what you (and OP) are looking for might be pragma shrink_memory [1].

[1] https://sqlite.org/pragma.html#pragma_shrink_memory

replies(1): >>45782776 #
5. asa400 ◴[] No.45782776{3}[source]
Ah, you're correct. I read too fast and missed that it was in-memory databases specifically!
6. pstuart ◴[] No.45783445[source]
If you're deleting all rows you can also just drop the table and recreate it.
7. ◴[] No.45783464[source]