Vacuum

Aperture: Speed Up Aperture By Rebuilding The Database Index

databasereindexicon
Everyone is excited about the discovery of using the sqlite vacuum command to rebuild the index for Mail.app. Well the same trick works for Aperture. Rebuilding the library database indexes is much faster than rebuilding the entire database. While probably not as effective, it does improve the speed of Aperture, especially for heavily-used libraries with a lot of deleted images. [Update: Aperture 2.0 has two databases: the Aperture.apdb database and a new one called BigBlogs.apdb. As currently written, this script does not touch the BigBlobs database.]

Here is the script. You can download a ZIPped version from the download page or paste the text below into Script Editor. Be careful of the single- and double-quotes getting modified in the process. They are all straight quotes. [Update: I added an improvement sent to me by Adam Tow. The script now only opens bundles and defaults to the Pictures folder.]

tell application "Aperture" to quit

set new_file to choose file with prompt "Select Aperture Libary to compact its database" default location (path to pictures folder) of type {"BNDL"}
set libname to (POSIX path of new_file) & "Aperture.aplib/"
set dbname to libname & "Library.apdb"
set sizeBefore to do shell script "ls -lah " & (quoted form of libname) & " | grep -E 'Library.apdb$' | awk {'print $5'}"

do shell script "/usr/bin/sqlite3 " & (quoted form of dbname) & " vacuum"

set sizeAfter to do shell script "ls -lah " & (quoted form of libname) & " | grep -E 'Library.apdb$' | awk {'print $5'}"

display dialog ("Database before: " & sizeBefore & return & "Database after: " & sizeAfter & return & return & "Now try it out!")

After prompting to select an Aperture library, it runs for a while (up to a minute on large libraries) and then shows a dialog box comparing the size of the library database before and after processing:
databasereindex
Let me know how much it helps.
|
The Bagelturf site welcomes Donations of any size