Simplify save_folder_names() and don't require any folders but Inbox.

In Gmail, you can _turn off_ arbitrary folders except the Inbox from
showing up in the IMAP API, presumably so e.g. people can reduce the
amount of data synced by their desktop email client. We'll have to add
in some mechanism of notifying users that they need to re-enable folders
in IMAP for some Inbox features to work properly, but for now, we can
just skip syncing those folders.
[SCHEMA] Index on imapuid.msg_uid, easuid.msg_uid, transaction.table_name.

Courtesy of our hot new slow query logging. Thanks @mg!
Throw a better error when incompatible stuff is passed to session.query().
Fix slow count() subqueries in webhooks startup.

SQLAlchemy by default when doing a count() on a query will issue the
count over a SELECT subquery, which, if you have a LOT of data you're
selecting, is incredibly slow. For example:

Slow query took 5402.23ms:
SELECT count(*) AS count_1 FROM
(SELECT transaction.table_name AS transaction_table_name,
transaction.record_id AS transaction_record_id, transaction.command AS transaction_command,
transaction.delta AS transaction_delta, transaction.additional_data AS transaction_additional_data,
transaction.id AS transaction_id, transaction.created_at AS transaction_created_at,
transaction.updated_at AS transaction_updated_at, transaction.deleted_at AS transaction_deleted_at,
transaction.namespace_id AS transaction_namespace_id
FROM transaction
WHERE transaction.deleted_at IS NULL AND transaction.table_name = %s AND
transaction.id > %s ORDER BY transaction.id ASC) AS anon_1 with params
('message', -1)

The way to get around this is to use func.count() on the primary key of
what you're trying to count. This works properly even with additional
filters applied.

(There's a reason for this madness, see the sidebar on
http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#counting.)