Speedup Firefox with VACUUM
I’ve seen a few posts about VACUUMing Firefox’s sqlite database for better performance, but each requires Firefox to be shut down.
Here is a way to VACUUM your places database from within the browser.
- Go to Tools -> Error Console
- Paste the following in the “Code:” text-box:
Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection.executeSimpleSQL("VACUUM"); - Press Enter
Your UI will freeze for a bit while the vacuum runs.
Resources:
- https://developer.mozilla.org/En/Updating_extensions_for_Firefox_3.5#Accessing_the_Places_database
- https://developer.mozilla.org/en/Storage
Cross post from my personal blog.
Mardeg 3:20 pm on August 20, 2009 Permalink |
First I had a syntax error on the . after DBConnection which made me suspect more code existed overflowing but hidden in your post with no way to scroll to the bit chopped off at the end. View -> Page Source to get the full code.
oremj 9:50 pm on August 20, 2009 Permalink |
Switched theme to solve the problem. Thanks for the heads up!
Dave 3:41 pm on August 20, 2009 Permalink |
Code is getting cut off after “DBConnection.” when I view this page under Firefox 3.5. RSS reader shows it fine. Must not be word-wrapping well here.
Robert Kaiser 3:46 pm on August 20, 2009 Permalink |
Actually, if this is that good and gives us that much speed, we really ought to do it right in the code by default. Nobody should need to execute strange-looking JS statements in an Error (!) Console just for getting a fast experience with Firefox. Hell, we market FF 3.5 as the fastest product we ever made. So let’s follow that and act on even improving it! Will you write the patch?
oremj 9:44 pm on August 20, 2009 Permalink |
There actually is already an active bug on that issue.
alanjstr 3:56 pm on August 20, 2009 Permalink |
1) I wonder how long until someone makes an addon for this.
2) How do I know it was successful? The console says [xpconnect wrapped mozIStorageConnection] so was that ok?
NTP 2:59 am on August 21, 2009 Permalink |
Well, someone has done it now
https://addons.mozilla.org/firefox/addon/13824
pd 9:02 pm on August 20, 2009 Permalink |
Once again a crappy too-narrow pre-canned blog theme destroys a useful blog post for the majority. For anyone who wants this tip to actually work, removes the new lines from this:
Components.classes["@mozilla.org/browser/nav-history-
service;1"].getService(Components.interfaces.nsPIPlacesDatabase).
DBConnection.executeSimpleSQL(“VACUUM”);
Down with fixed with pre-canned, out-of-the-box blog themes! Think about it, don’t just post it!
Tomer 12:16 am on August 21, 2009 Permalink |
Looks like it does something good to awesomebar, and it loads faster now.
Is it possible to use a background worker thread in order to eliminate the UI freeze?
Fernando 4:48 am on August 21, 2009 Permalink |
Addon
But I don’t tested yet
https://addons.mozilla.org/en-US/firefox/addon/13824
Revertron 5:21 am on August 21, 2009 Permalink |
Hi all
Meet the fresh-new extension for Vacuum-cleaning your Places: https://addons.mozilla.org/ru/firefox/addon/13824/
You can write comments on this right there, on mozilla site.
AndyC 5:51 am on August 21, 2009 Permalink |
Ubiquity!
CmdUtils.CreateCommand({
names: ["vacuum"],
description: “Clean FF sqlite dbs”,
execute: function(input) {
Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsPIPlacesDatabase)
.DBConnection
.executeSimpleSQL(“VACUUM”);
}
});
alanjstr 6:23 am on August 21, 2009 Permalink |
Ok, I went back and got the full string from the page source. My UI didn’t freeze and I got no messages on the console. Did it work?
David 6:51 am on August 21, 2009 Permalink |
For those who use userChrome.js, this code should add this command to the Tools menu:
var menuitem = document.createElement("menuitem");menuitem.setAttribute("label", "Database Vacuum");
menuitem.setAttribute("accesskey", "V");
menuitem.setAttribute("oncommand", 'Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection.executeSimpleSQL("VACUUM");');
document.getElementById("devToolsSeparator").parentNode.insertBefore(menuitem, document.getElementById("devToolsSeparator"));
Anonymous 11:11 am on August 22, 2009 Permalink |
Thank you!
Philipp 3:03 am on August 22, 2009 Permalink |
Way faster! Thanks!
Jay 1:08 pm on August 25, 2009 Permalink |
Seems to cause some problems with Google Gears offline function for Gmail. I had to unauthorize, and then reauthorize to rebuild the databases. The problem started around the same time I did the procedure here….
Jay 1:20 pm on August 25, 2009 Permalink |
A clear cache seems to have fixed it. So not sure if it’s related or not…..
Luca 7:43 am on August 28, 2009 Permalink |
Hi, I was trying to implement this asynchronously in an extension, but the UI keeps freezing even if access the database interface via executeAsync:
Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection.executeAsync([Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection.createStatement(“VACUUM”)], 1);
Do you know why?
fastfast 7:56 am on August 28, 2009 Permalink |
Нихрена не работает.
Steve 6:08 pm on August 29, 2009 Permalink |
I’ve been using BleachBit for some time and it’s quite effective at cleaning out crap not only in FF but other progies as well. You can run it anytime and it does the trick.
124 2:32 am on August 31, 2009 Permalink |
There is an new Improves Version 0.3 of the Addon:
https://addons.mozilla.org/en-US/firefox/addon/13878