Compact Firefox Databases To Improve Performance Or Not?

There is a lot of confusion around the net as to whether it is a good idea to compact (defragment) Firefox databases or not. I have reviewed the latest position below.

Mozilla Firefox uses Sqlite databases to store bookmarks, history and other data. Sqlite is a light but powerful database management system and is also used by other web browsers like Chrome and Opera for local data storage.

One problem Firefox users may encounter is that over time the Sqlite databases become fragmented and larger than they need to be.

What Causes Database Fragmentation? Sqlite.org state: “Frequent inserts, updates, and deletes can cause the database file to become fragmented – where data for a single table or index is scattered around the database file”.

They also note that “when a large amount of data is deleted from the database file it leaves behind empty space, or “free” database pages.

Just as a fragmented hard drive can reduce the performance of Windows, a badly fragmented and overly large Sqlite database can reduce the speed of Firefox.

According to Mozilla’s Wiki: “Fragmented Sqlite databases are known to make the Awesomebar performances bad, and cause other performance problems”. Note that this statement is not restricted to the main places.sqlite database – Firefox has many other sqlite databases which can also impact on performance.

If a database is larger than it has to be this can also increase database access times and, potentially, slow down Firefox. It therefore makes sense that defragmenting Firefox databases could help improve the speed and performance of Firefox. So far so good.

Can Firefox Databases Be Defragmented?

Yes, but it is not as simple as defragmenting a hard drive. The method used to defragment a Firefox Sqlite database is to totally rebuild it without fragmentation by copying its contents into a temporary database file and then overwriting the original back again.

This process is usually called compacting (or ‘vacuuming’) the database.

Should You Compact Firefox Databases?

The source of most confusion and incorrect advice arises from the version of Firefox used and the specific Sqlite database discussed.

Firefox 3.6 and earlier

There is a strong case for compacting the databases – forums often recommend installing an add-on (e.g. the Vacuum Places Improved addon) to compact the places.sqlite database but external programs like Speedyfox and Ccleaner offer to compact all Firefox databases which makes much more sense.

In my opinion, the advice to compact databases in Firefox 3.6 and earlier is correct as these versions did not compact them automatically.

Firefox 4 to Firefox 11 (and later)

Firefox 4 introduced a new integrated process to automatically compact the main places.sqlite database behind the scenes – per Bugzilla, it does this once a month whilst Firefox is idle. This is still the case with Firefox 11 (the latest version at the time of writing).

In addition, the size of places.sqlite is now inflated to a minimum size of 10MB – to reduce the likelihood of future fragmentation. In theory, it should no longer be necessary to compact the places.sqlite database using an add-on or external program – as long as it is actually being compacted…

Check If Firefox 4 and Later Is Compacting places.sqlite

Go to about:config and search for the preference named storage.vacuum.last.places.sqlite – it should have a numeric value which represents the last date/time that the integrated vacuum took place.

The numeric value is a Unix timestamp – to find the readable date and time, copy the value into the Unix Timestamp box of the Online Conversion site here and press Submit e.g. 1332175724 converts to a time on 19th March 2012.

If the date is less than a month ago, you know Firefox 4+ is vacuuming the places.sqlite database successfully on a monthly basis – no further compacting is required for that particular database.

What About The Other Databases?

Some people misunderstand the above feature and think that, because Firefox 4+ ‘vacuums databases’ automatically, no further action is required. However, this view ignores the fact that the new integrated feature vacuums only the ‘places’ database – Firefox uses many other databases and they are equally at risk of fragmentation and excessive size.

It could therefore still be helpful to use an external tool like SpeedyFox or Ccleaner to compact all Firefox databases at the same time.

Compact Firefox Databases With Ccleaner

Compacting databases means rebuilding them from scratch so is not without risk. Some users in forums have reported Firefox problems or database corruption after using third party tools to compact databases so it is highly recommended to backup Firefox first just in case. If you use other Mozilla products like Thunderbird, take a full backup of them too.

Warning: the main Sqlite databases used by Firefox are stored in your Firefox profile folder – take a backup of it and a full Firefox backup e.g. with MozBackup.

1. Close Firefox completely – check in Task Manager that Firefox.exe is no longer running to make sure
2. Open Ccleaner (see full review here if required) and go to the Applications tab
3. Under the Firefox/Mozilla section, tick the Compact Databases box
4. Select or deselect any other items required then Run Cleaner as usual
5. After the cleanup has completed, open Firefox and you may notice some speed improvement – particularly with the speed of opening
6. Check that Firefox (and other Mozilla products if applicable) still works as expected – especially the Bookmarks and the Awesome (address) bar. If not, revert back to your previous profile or full backup.

Conclusion

There are a lot of misconceptions about whether to compact Firefox databases, depending on which version of Firefox is used. For users of Firefox 3.6 and earlier it makes logical sense to vacuum the databases.

For users of Firefox 4 to 11 (and later) the case is less clear cut – Firefox should be compacting the main ‘places’ database itself but, even if it does, there are many other databases which may become fragmented and overly large.

For every horror story of subsequent database corruption there are plenty more stories of drastically improved Firefox performance, particularly startup times. If users are sure they have a (known good) full backup of Mozilla products there seems little harm in trying.

I personally have never encountered any issues using Ccleaner to compact Firefox databases – in some cases Firefox was noticeably quicker afterwards whilst in others it appeared to make no difference. A lot will depend on whether or not the databases were badly fragmented to start with…

Perhaps more so than most articles at TechLogon, your mileage may vary with this one so I have marked it for Advanced users. Firefox users may also like to review my general guide to speeding up Firefox.

2 thoughts on “Compact Firefox Databases To Improve Performance Or Not?”

  1. Hi Roy. Thanks for the post. I followed all the steps above with my Firefox version 11 installation. I didn’t detect any change in start-up time of the browser or performance. However, this post did prompt me to backup my Firefox settings and update to the latest CCleaner. :) and even though this post is dated 4/1, it’s not an April Fool’s post!

    • Hi Mark, I suspect it is of more benefit to those with the most ‘cluttered’ FF installs e.g. loads of add-ons, hundreds of bookmarks and never reinstalled since FF2. If yours is tight and light there likely won’t be much it can compact.

      You may have noticed Ccleaner has the same option for Chrome too. I haven’t looked into that one yet but Chrome is typically quicker anyway as users tend not to overload it with as many addons

Comments are closed.