On 2/19/20, Olivier Mascia <o...@integral.be> wrote:
> Hello,
>
> As part of a rare database "maintenance"...
> Does VACUUM, in essence, implies whatever actions REINDEX would do?
> Would REINDEX before VACUUM make any more sense?
>
> And what about ANALYZE? Would it be wise or useless, to run it after VACUUM?

VACUUM does not imply REINDEX.  Those are separate actions.  VACUUM
repacks all the content in to minimal space, and thus (probably) makes
the database file a little smaller.  It also reorganizes the pages so
that tables are grouped together and are in search order, which might
make table scans faster, depending on the underlying filesystem.

REINDEX rebuilds an index from scratch based on the original table
data.  This amounts to a big sort.  REINDEX was invented so that if
you change the definition of a collating function, you can run REINDEX
on all indexes that use that collating function and it will reorder
the indexes into the new correct order.  REINDEX will also fix any
index corruption.  But if you have index corruption, that is a symptom
of deeper problems which should be addressed. You should not
paper-over such problems by running REINDEX.

VACUUM is independent of ANALYZE.  The information computed by ANALYZE
is the same before and after VACUUM.  There is no benefit to running
ANALYZE after running VACUUM if the ANALYZE data (the content of the
sqlite_stat1 table) is still up-to-date.
-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to