[H-GEN] Speeding up Firefox

Russell Stuart russell-humbug at stuart.id.au
Wed Aug 18 21:41:39 EDT 2010


I discovered something the other day that I found both surprising and
useful.

When I first installed Firefox it had a nice & fast auto-completion
feature for the address bar, forms an other things.  But as time went on
it changed from nice and fast to slow but still useful, and then to just
plain obnoxious as I drummed my fingers waiting for the HDD light to
switch off while it did auto the complete.

Firefox implements those features by using sqlite3 as a backend.  I
guessed the cause was those sqlite3 databases were growing in size.
Looking at the databases my firefox use suggests that might be the case:

        -rw-r--r-- 1 rstuart it 2.0K Aug 19 10:29 search.sqlite
        -rw-r--r-- 1 rstuart it 2.0K Aug 19 10:29 permissions.sqlite
        -rw-r--r-- 1 rstuart it  18K Aug 19 10:29 content-prefs.sqlite
        -rw-r--r-- 1 rstuart it  23K Aug 19 10:29 webappsstore.sqlite
        -rw-r--r-- 1 rstuart it 268K Aug 19 10:29 downloads.sqlite
        -rw-r--r-- 1 rstuart it 303K Aug 19 10:29 signons.sqlite
        -rw-r--r-- 1 rstuart it 403K Aug 19 10:29 cookies.sqlite
        -rw-r--r-- 1 rstuart it 2.2M Aug 19 10:29 formhistory.sqlite
        -rw-r--r-- 1 rstuart it  20M Aug 19 10:31 urlclassifier3.sqlite
        -rw-r--r-- 1 rstuart it  24M Aug 19 10:29 places.sqlite

It seemed reasonable that searching a 24M as I type might unavoidably
take a while.

Turns out it isn't so.  The reason sqlite3 was taking a while to search
those databases wasn't because they are particularly big.  It is because
they had became fragmented over time.

It isn't difficult to unfragment them.  One way is ensure firefox isn't
running, then run these commands:

  $ cd ~/.mozilla/firefox/SOMEJUNK.default
  $ for f in *.sqlite; do sqlite3 $f 'VACUUM;'; done

A second way is to get firefox to run those commands for you.  Doing
this worked for me, but it seems a lot of people have problems with it.
Also it only cleans up the navigation databases, whereas the previous
method cleans up all of them.

  1.  From Firefox's menu, go to Tools, Error Console.

  2.  In the "Code" field enter this string:

      Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection.executeSimpleSQL("VACUUM");

  3.  Click the "Evaluate" button.  If it worked the UI will freeze for
      a while.

A third way is to install a Firefox plugin that will do it for you.
Again, most of these only clean up the navigation databases, but on the
up side some will automatically do it periodically for you.  You can
find them by entering "vacuum" into the search for add-ons box:

  https://addons.mozilla.org/

Assuming you have plenty of free disk space (so your disk isn't
fragmented) doing any of these things should make URL entry into firefox
roughly as fast as the day you installed it.  Of course, if you think
firefox ran like a dog on the day you installed it then this isn't going
to help.






More information about the General mailing list