Firefox databases VACUUM and REINDEX

A clever trick to improve the speed of your firefox browser is by vacuuming its sqlite database. The VACUUM process rebuilds the database, thus defragmenting it, reduces the size and makes searching in it faster, using disk more efficiently may also reduce the load on your disk as it reads in sequence from my sectors. In general, this applies to any database that does not automatically perform vacuum / defrag on itself.

The process of defragmenting the Firefox database itself is quite trivial – we perform sqlite3 db-file VACUUM in the firefox profile directory. In linux, the path to it is usually ~ / .mozilla / firefox / random-name.default. In principle, you should only have 1 directory in .mozilla / firefox if you have more you can check ~ / .mozilla / firefox / profiles.ini for the correct directory in your browser's profile. Since I don't care about doing the process by hand, I wrote an elementary script to defragment the databases.:

for db in $(find ~/.mozilla/firefox/$(grep Path ~/.mozilla/firefox/profiles.ini | cut -d'=' -f2) -maxdepth 1 -name "*.sqlite" -type f)
   echo "VACUUM ${db}"
   sqlite3 ${db} VACUUM
   sqlite3 ${db} REINDEX

After executing the script, the search in the history and the loading of the fox itself is significantly faster. I guess the script can be used in Mac OS with small modifications.

p.s Here is the option for Mac OS X. – tested on Mac OS X Sierra. We have to force the delimiter to be a new line because of space in the path to the folder that contains the firefox profile

for db in $(find ~/Library/Application\ Support/Firefox/$(grep Path ~/Library/Application\ Support/Firefox/profiles.ini | cut -d'=' -f2)  -maxdepth 1  -name "*.sqlite" -type f)
echo "VACUUM && REINDEX ${db}"
sqlite3 "${db}" VACUUM;
sqlite3 "${db}" REINDEX;

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti SPAM *