The vacuum removes empty pages by rewriting the database ground up.

https://www.sqlite.org/lang_vacuum.html

"The VACUUM command works by copying the contents of the database into a
temporary database file and then overwriting the original with the contents
of the temporary file. When overwriting the original, a rollback journal or
write-ahead log WAL file is used just as it would be for any other database
transaction. This means that when VACUUMing a database, as much as twice
the size of the original database file is required in free disk space."

I'm not aware whether or not the engine actually checks to see if there are
free pages.  I don't see anything in the documentation on that page that
says that it does a pre-check on empty pages before making the decision to
do the work of a vacuum.  But the vacuum also defrags the database as well
(Internally) and I doubt that there'd be a check for fragmentation of
sorts, so I'd lean towards this is a command that will do its deed
regardless.

Try writing out a large database (Something that will take time to read and
write.  Maybe a few hundred meg) and run two vacuums one right after
another, no other transactions done.


On Sat, Oct 1, 2016 at 10:24 PM, Howard Chu <h...@symas.com> wrote:

> Domingo Alvarez Duarte wrote:
>
>> Hello Simon !
>>
>> I already did it without using "wal" and the result was the same.
>>
>> And even for my surprise in one try I stopped at the middle performed an
>> "analyze" and the performance deteriorated a lot to a point that I needed
>> to
>> delete the stats tables to get the better performance without "analyze".
>>
>> I also tried with the lsm module and got a bit better performance but
>> with an
>> irregular timing and a bigger disk usage (20%).
>>
>> Also tested with lmdb with an astonishing insertion rate but with a lot
>> more
>> disk usage and irregular timing.
>>
>
> Using LMDB the VACUUM command is supposed to be a no-op; at least that's
> how I intended it. Since LMDB deletes records immediately instead of
> leaving tombstones, there is nothing to vacuum.
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to