Set temp store to be in-memory #40
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #39
For some queries, SQLite needs to make a temporary file to store intermediate results. By default, this is set to be stored on the disk to avoid high memory usage, however it is possible to configure it to store this in-memory. The draw-back, obviously, is higher memory usage.
Due to complications with file permissions in the work folder in the sim, SQLite was not able to properly utilize the temporary dir that is set (even with manually setting
sqlite3_temp_directory), so we are forced to move it to in-memory.Using the query in #39, here is the WASM memory view before execution:


And here it is after:
The linear memory difference is 9.308MB (the query did not take up 100% of that difference, as there are other allocations that can bump that; however the query was the main contributor). The sim properly decommitted the pages shortly after. Running the query twice before the sim decommits the pages does not lead to an increase in the linear memory size, so SQLite is properly cleaning itself up in between.
Developers should be wary to avoid large queries that may result in larger allocations here.