The mailbox_messages table

mailbox_messages links mailboxes and messages together. The flags and annotations tables are also tied to it since flags and annotations aren't shared when a message occurs in more than one mailbox.

This is perhaps the most central table in the entire database. For every message which is visible in a mailbox, there is a row in this table. (Some messages aren't visible, usually because they've just been deleted and not yet cleaned up. Others are visible in more than one mailbox, and so have more than one mailbox_messages rows.)

mailbox and message tie this row to the mailboxes and messages tables.

The uid column is the message's number in this mailbox. Whenever a message is added to a mailbox, it receives a number larger than all other messages in the mailbox. (This is initialised from mailboxes.uidnext.)

The modseq is a change counter. Whenever a message's flags or annotations change, Archiveopteryx increases modseq. Smart IMAP clients can use this with CONDSTORE to save bandwidth.

The seen and deleted columns store the IMAP \Seen and \Deleted flags. Most flags are stored in the flags table, but these two are used so much that we keep them here for performance.

create table mailbox_messages ( -- Grant: select, insert, update mailbox integer not null references mailboxes(id), uid integer not null, message integer not null references messages(id), modseq bigint not null, seen boolean not null default false, deleted boolean not null default false, primary key (mailbox, uid) );

The mailbox_messages table was introduced in version 2.06.

In case of questions, please write to info@aox.org.

Relevant links

About this page

Last modified: 2010-11-19
Location: aox.org/db/mailbox_messages