Specksynder
Specksynder

Reputation: 843

Data storage space for temporary databases in SQLite 3

I created a SQLite database as a temporary database(by specifying an empty filename in sqlite3_open() ). I also specified a limit on the amount of memory that can be used by the database to be about 200KB by using 'sqlite3_soft_heap_limit64().

As I keep inserting database rows, I see that the memory used by the database(obtained by sqlite3_memory_used() ) goes up until it reaches 200KB, and then after that, stays constant, even with continued row insertions.

Where is the extra row space for insertions after reaching the limit allocated from? Is it a temporary file created on disk? I want to know the location so that I can control/configure any space issues that may result from such allocation.

Upvotes: 3

Views: 790

Answers (1)

Specksynder
Specksynder

Reputation: 843

I dug into SQLite code to see how this is done. On Unix platforms, SQLite will try to create a temporary file in either:

  1. the location pointed to by the SQLite global variable: sqlite3_temp_directory
  2. the directory pointed to by any of the environment variables 'TEMP', 'TMP', or 'TMPDIR', in that order.

Upvotes: 4

Related Questions