Firefox databases for better performance

Since Firefox 3.0, bookmarks, history and most storage is kept in SQLite databases. Also, the default history time span was raised from 9 to 90 days as it became more discoverable and useful thanks to the awesome bar, so depending on your browsing habits it could represent some pretty large databases.

Aas any other database, SQLite databases become fragmented over time and empty spaces appear all around. But, since there are no managing processes checking and optimizing the database, these factors eventually result in a performance hit. So, a good way to improve startup and some other bookmarks and history related tasks is to defragment and trim unused space from these databases.

To do this:

Step 1: get sqlite3, a single file command line SQLite database manager, for your platform (available for Linux, Windows, and Mac OS X).

Step 2: Copy the downloaded binary to your profile folder where all your .sqlite files reside.

Step 3: Close Firefox.

Step 4: From a command line prompt in your profile folder, run:

sqlite3 [SQLite database] VACUUM

replacing [SQLite database with the name of a SQLite file, like places.sqlite.

On Windows, to defragment all SQLite databases in one command, run:

for %a in (*.sqlite) do (sqlite3 %a vacuum)

I ran the script in a couple of machines resulting in a noticeable reduction of start up times after databases defragmentation:

Machine 1: 1 window, 20 tabs
places.sqlite size before vacuum: 10 MB
places.sqlite size after vacuum: 9 MB
Cold startup Before: 11 s
Cold Startup After: 8 s

Machine 2: 3 windows, 25 tabs
places.sqlite size before vacuum: 40 MB
places.sqlite size after vacuum: 27 MB
Cold startup Before: 10 s
Cold Startup After: 7 s

So if this is all good, why hasn’t Mozilla included this defragmenting procedure? The thing is they want to but still haven’t found the best way to do so. One of the suggestions so far has been to do it during an update: it has the advantage of been semi regular (about every six weeks), and already interrupts the user workflow (and requires the database files been released, turning Firefox off).

A good option for Windows users is IniFox, by InfoSpyware which simply packs sqlite3 and an interactive batch file that defragments all databases in your profile as described above. You will still have to download and copy, but you will avoid opening a console and repeating the steps for all the databases.

If you try this mechanism, please take some time to get your before and after times and sizes and share your results in the comments. For cold startups, you will have to restart your system to get valid results.

Comments

Popular posts from this blog

How To View The Contents In Firefox Cache Locations

How to Use ISO Files in Windows XP

How to using tabbed bookmarks in Safari and Firefox