tisdag 9 november 2010

Time to clean up your iPhoto library.

Like I've written before, iPhoto is a database application developed around the SQLite database engine. Sometimes database engines allocate more and larger pages than needed, and this extra space is most often kept allocated even when you delete data from the database.

So, it might be worth-while to clean up some of this allocated-but-unused once in a while, to make iPhoto run a bit smoother. In database terminology, you need to VACUUM your database, and this is what I will show you how to do below.

First, we open up the terminal and move into the iPhoto library. Please make sure that iPhoto is not running while you do this, just in case.

$ cd Pictures/iPhoto\ Library/

Inside this folder, there are a bunch of .db files:

$ ls -al *.db

-rw-r--r--  1 zak  staff   6173696 Nov  9 07:34 face.db

-rw-r--rw-  1 zak  staff  14992384 Nov  9 07:28 face_blob.db

-rw-r--rw-  1 zak  staff  24619008 Nov  9 07:57 iPhotoAux.db

-rw-r--rw-  1 zak  staff   7424000 Nov  9 08:00 iPhotoMain.db

We can use a bash for loop to loop over the database files and vacuum them all:

$ for dbase in *.db; do sqlite3 $dbase "vacuum;"; done

Now, when we examine the size of the files again, we see that they are smaller. Please note that no information is lost here, we are just cleaning out empty space.

$ ls -al *.db

-rw-r--r--  1 zak  staff   4704256 Nov  9 15:23 face.db

-rw-r--rw-  1 zak  staff  14746624 Nov  9 15:24 face_blob.db

-rw-r--rw-  1 zak  staff  18824192 Nov  9 15:24 iPhotoAux.db

-rw-r--rw-  1 zak  staff   5400576 Nov  9 15:24 iPhotoMain.db

In my case, I was able to get rid of a couple of MBs of unused, but allocated, space, and hopefully have a more pleasant experience using iPhoto.

Inga kommentarer:

Skicka en kommentar