We get a lot of questions that center around misconceptions about Smart Folders in Tiger’s Mail program. This is a quickie to explain away some of these misconceptions as well as give a little insight into how they work.

Smart Folders don’t contain mail. Smart Folders don’t really even exist. A Smart Folder is really just a saved search and the contents of the Smart Folder are determined anew every time you click on it to check it.
That said, there are some speedups in place. When you go into Mail and search on something, you’ll see a little bar come up that gives you four search options: Entire Message, To, From, Subject. If you use sqlite3 to view the “Envelope Index” file in ~/Library/Mail you’ll see the cached information about the Mail folder’s messages, which includes the sender, recipient, and subject line (and a variety of flags).
sqlite> .schema messages
CREATE TABLE messages (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, message_id, in_reply_to, remote_id INTEGER, sender INTEGER, subject_prefix, subject INTEGER, date_sent INTEGER, date_received INTEGER, date_last_viewed INTEGER, mailbox INTEGER, remote_mailbox INTEGER, original_mailbox INTEGER, flags INTEGER, read, flagged, size INTEGER, color, encoding, pad);
CREATE INDEX date_index ON messages(date_received);
CREATE INDEX date_last_viewed_index ON messages(date_last_viewed);
CREATE INDEX message_flagged_index ON messages(flagged);
CREATE INDEX message_mailbox_index ON messages(mailbox, date_received);
CREATE INDEX message_message_id_index ON messages(message_id);
CREATE INDEX message_read_index ON messages(read);
CREATE INDEX message_remote_mailbox_index ON messages(remote_mailbox, remote_id);
CREATE INDEX message_sender_index ON messages(sender);
CREATE INDEX subject_index ON messages(subject);
CREATE TRIGGER after_delete_message AFTER DELETE ON messages BEGIN DELETE FROM threads WHERE threads.message_id OLD.ROWID; DELETE FROM attachments WHERE attachments.message_id OLD.ROWID; DELETE FROM recipients WHERE recipients.message_id == OLD.ROWID; DELETE FROM subjects WHERE ROWID = OLD.subject AND (SELECT COUNT() FROM messages WHERE subject = OLD.subject) = 0; DELETE FROM addresses WHERE ROWID = OLD.sender AND (SELECT COUNT() FROM messages WHERE sender = OLD.sender) + (SELECT COUNT() FROM recipients WHERE address_id = OLD.sender) = 0; END;
Now, when you make a Smart Mailbox on anything in this table, the transaction has two properties. First, it’s fast. Second, it’s updated live when things change. If you stick to these properties, Mail just runs a SQL query against this database and gives you the results. Very simple.
If you, however, create a Smart Mailbox with “Entire Message” selected then Mail actually calls Spotlight to do a search of the message contents as well and then compares the results of the other criteria against the results of Spotlight and then gives you the results. To avoid taking over the system with the Spotlight results of a dozen mailboxes, Mail will not do live updates on Smart Mailboxes with “Entire Message” as a criterion.
Whatever criteria you use in your Smart Mailbox, it’s really just searching all of your other mailboxes for this information and, thus, isn’t holding your mail. You can’t move mail into a Smart Mailbox or out of it. If you delete it, nothing goes except the mailbox. It just ain’t real.
Post new comment