Skip to content

Commit e042630

Browse files
committed
docs: document PRAGMA temp_store for VACUUM on large databases
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
1 parent 8f0c06e commit e042630

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

docs/python-api.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,16 @@ You can optimize your database by running VACUUM against it like so:
26512651
26522652
Database("my_database.db").vacuum()
26532653
2654+
Running VACUUM (or other operations that rebuild the database, such as :ref:`table.extract() <python_api_extract>`) against a very large database may fail with ``OperationalError: database or disk is full`` when ``/tmp`` does not have enough space for the temporary rebuild. SQLite uses a temporary file by default; you can ask it to use memory instead by setting `PRAGMA temp_store <https://www.sqlite.org/pragma.html#pragma_temp_store>`__ to ``MEMORY`` on the connection:
2655+
2656+
.. code-block:: python
2657+
2658+
db = Database("my_database.db")
2659+
db.execute("PRAGMA temp_store = MEMORY")
2660+
db.vacuum()
2661+
2662+
This makes SQLite hold the temporary state in RAM, which avoids the ``/tmp`` size limit at the cost of additional memory usage.
2663+
26542664
.. _python_api_wal:
26552665
26562666
WAL mode

0 commit comments

Comments
 (0)