I'm trying to run the VACUUM
command on my database, but I seem to run out of space:
> sqlite3 mydatabase.db "VACUUM" Error: database or disk is full
The database is about 36 GB and the drive that I'm running it on looks like (via df -h
):
Filesystem Size Used Avail Use% Mounted on /dev/sda2 406G 171G 215G 45% /home
So I am clearly above the double size limited needed. What can I do to allow the vacuum command to run?
VACUUM command cleans the main database by copying its contents to a temporary database file and reloading the original database file from the copy. This eliminates free pages, aligns table data to be contiguous, and otherwise cleans up the database file structure.
If you find the 'SQLite Database Disk Image is malformed' error, export your database into an SQL file. To export the data, click the File tab followed by Export>>Database to SQL file. The Export SQL dialog box appears on the screen; select the objects you want to export and define the other options.
SQLite database files have a maximum size of about 140 TB. On a phone, the size of the storage (a few GB) will limit your database file size, while the memory size will limit how much data you can retrieve from a query. Furthermore, Android cursors have a limit of 1 MB for the results.
You may see the "database disk image is malformed" error in TekRADIUS log. This could happen during unplanned shutdown or reboot. The error indicates that one or more of the sqlite3 databases may have become corrupted. You need to have sqlite3.exe to diagnose and fix the problem.
To allow the VACUUM command to run, change the directory for temporary files to one that has enough free space.
SQLite's documentation says the temporary directory is (in order):
SQLITE_TMPDIR
environment variable; orTMPDIR
environment variable; or/var/tmp
; or/usr/tmp
; or/tmp
; or.
, the current working directoryIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With