1.

2.

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

3.

there is a new experimental Firefox addon

Open the Error Console: Tools menu/Error ConsoleIn the Code text box paste this (it’s a single line):Press Evaluate. All the UI will freeze for a few seconds while databases are VACUUMed.Also,which makes this process more comfortable by providing the means to run the database optimization with a single click. The will optimize the SQLite databases of the active Firefox profile whenever its button in the Firefox status bar is pressed.