SQLite Forum

Defragment a table ?
Get or compile the "[sqlite3_analyzer][2]" (or "[sqlite3_analyzer.exe][2]" utility
program.  You can get precompiled binaries from the [SQLite download page][1].
This program is part of the "sqlite-tools-*" packages.  Once you have the
utility, run it against your database.  It will generate information about
how much space each of your tables is using, the average row size, the
packing efficiency, and so forth.  That information might provide new
insight into what is going on.

If possible, post the output of "sqlite3_analyzer" here.

[1]: https://www.sqlite.org/download.html
[2]: https://www.sqlite.org/sqlanalyze.html