Monday, 9 March 2009

How to Speedup Firefox using SQLite VACUUM command

Firefox can run faster if it's database is purged of empty entries. Firefox database is using SQLite to manage its database.


Requirements

SQLite >=3.0

You can install using the following command

sudo apt-get install sqlite3

Now you need to open file ffast(you can give any name) using the following command

gedit ffast

copy and paste the following script

#!/bin/bash

username=$(whoami)
proc="$(ps aux | grep $username | grep -v $0 | grep firefox | grep -v grep)"
if [ "$proc" != "" ]
then
echo "shutdown firefox first!"
exit 1
fi

curdir=$(pwd)

for dir in $(cat ~/.mozilla/firefox/profiles.ini | grep Path= | sed -e 's/Path=//')
do
cd ~/.mozilla/firefox/$dir 2>/dev/null
if [ $? == 0 ]
then
echo "i'm in $(pwd)"
echo -e " running...\n"

for F in $(find . -type f -name '*.sqlite' -print)
do
sqlite3 $F "VACUUM;"
done

echo -e "done in $(pwd) ...\n"
else
echo -e "\n !!!! Error while entering directory $dir !!!!\n"
fi
done
echo "Job finished";

cd $curdir

Save and exit the file

Now you need to open your home folder select your file in this case ffast right-click on it, select properties. Then select Permissions tab and check the "Allow executing file as program" click Close.

Then close Firefox and run your script from terminal using

./ffast

when script done it's work start Firefox and you should see how fast your firefox will run.

2 comments:

Ed said...

Useful, if slightly clumsy script. Thanks.

Might I suggest splitting the cd command in two:

cd ~/.mozilla/firefox/
cd $dir 2>/dev/null

That way it'll work in the case that a profile is not in the ~/.mozilla/firefox directory.

10ksnooker said...

used the script and it sped up Firefox, but it returned this output when used on a 'gears' profile

!!!! Nisam uspio uci u direktorij 3qvudem2.FF3, preskacem ga !!!!


!!!! Nisam uspio uci u direktorij Test, preskacem ga !!!!


!!!! Nisam uspio uci u direktorij b0gbuccz.FireFox, preskacem ga !!!!


!!!! Nisam uspio uci u direktorij 3, preskacem ga !!!!

What's that?