My iPhoto ’08 used to start in seconds despite the 30,000+ photos I kept in it. But after I installed iLife ’09 and upgraded my iPhoto library, iPhoto ’09 would hang for several minutes with the dreaded beach ball on startup. Even worse, though was that opening any event would trigger another hang of a minute or more, as would viewing a photo full-screen. (Once these initial hangs were over and done with, the app would work normally.)
Inside the iPhoto Library Package, there are four SQLite databases (face_blob.db, face.db, iPhotoAux.db and iPhotoMain.db). I found that by vacuuming all four of these databases, I restored iPhoto ’09’s performance back to something on par with its predecessor.
Open Terminal and cd into your iPhoto Library (by default, cd “~/Pictures/iPhoto Library”). Once there, execute the following command:
for dbase in *.db; do sqlite3 $dbase "vacuum;"; done