This is an unbelievable trick. If you’ve been running Firefox for a long time, it gets a lot more sluggish. Here’s how to optimize its databases and give it back its youthful vigor.First, go to Tools, Error Console. Copy and paste this long and obnoxious line in:
Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection.executeSimpleSQL("VACUUM");
Click Evaluate and wait. Firefox will appear to lock up, but fear not, when the query finishes, it’ll recover with a vengeance, loading faster, rendering pages faster, and doing just about everything faster.
The difference could be enough to cure new-computer fever, in some cases.
You can close the Error Console window after it finishes.
What this trick does, from a technical standpoint, is dump all the empty space in the databases where it stores all of your data (bookmarks, browsing history, usernames, stuff like that), making it smaller and easier to manage, and, in turn, faster. Whenever data expires, it’s blanked out rather than truly deleted, so the databases just keep on growing over time, contributing to Firefox’s slowdown.

David Farquhar is a computer security professional, entrepreneur, and author. He has written professionally about computers since 1991, so he was writing about retro computers when they were still new. He has been working in IT professionally since 1994 and has specialized in vulnerability management since 2013. He holds Security+ and CISSP certifications. Today he blogs five times a week, mostly about retro computers and retro gaming covering the time period from 1975 to 2000.

It does seem to work as advertised. One caveat though, I waited a long time without seeing any visible indication that it was through. Finally gave up and closed it. When I went back into Firefox it was significantly faster. Thanks for sharing this with us.
Actually if it’ll let you close down, then you know it’s done. The only visible indication you have is that the window hangs.
I’m amazed at the difference it made on my machine, but I probably had at least three years’ worth of cruft in there. If I imported my profile from another PC, it could have been more than that.