mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-27 11:24:33 +02:00
sqlite-utils optimize command, .optimize() and .detect_fts() table methods
This commit is contained in:
parent
015bd2a840
commit
0a8194e730
7 changed files with 146 additions and 4 deletions
15
docs/cli.rst
15
docs/cli.rst
|
|
@ -27,3 +27,18 @@ Vacuum
|
|||
You can run VACUUM to optimize your database like so::
|
||||
|
||||
$ sqlite-utils vacuum mydb.db
|
||||
|
||||
Optimize
|
||||
========
|
||||
|
||||
The optimize command can dramatically reduce the size of your database if you are using SQLite full-text search. It runs OPTIMIZE against all of our FTS4 and FTS5 tables, then runs VACUUM.
|
||||
|
||||
If you just want to run OPTIMIZE without the VACUUM, use the ``--no-vacuum`` flag.
|
||||
|
||||
::
|
||||
|
||||
# Optimize all FTS tables and then VACUUM
|
||||
$ sqlite-utils optimize mydb.db
|
||||
|
||||
# Optimize but skip the VACUUM
|
||||
$ sqlite-utils optimize --no-vacuum mydb.db
|
||||
|
|
|
|||
|
|
@ -298,6 +298,25 @@ If you insert additional records into the table you will need to refresh the sea
|
|||
}, pk="id")
|
||||
dogs.populate_fts(["name", "twitter"])
|
||||
|
||||
``.enable_fts()`` defaults to using `FTS5 <https://www.sqlite.org/fts5.html>`__. If you wish to use `FTS4 <https://www.sqlite.org/fts3.html>`__ instead, use the following:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
dogs.enable_fts(["name", "twitter"], fts_version="FTS4")
|
||||
|
||||
Optimizing a full-text search table
|
||||
===================================
|
||||
|
||||
Once you have populated a FTS table you can optimize it to dramatically reduce its size like so:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
dogs.optimize()
|
||||
|
||||
This runs the following SQL::
|
||||
|
||||
INSERT INTO dogs_fts (dogs_fts) VALUES ("optimize");
|
||||
|
||||
Creating indexes
|
||||
================
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue