Query message IDs rather than metadata when only IDs are needed
This branch exposes the DB's existing query method for message IDs through the DatabaseComponent and ClientHelper interfaces, so that we can avoid loading and parsing metadata if we're only interested in the message IDs that match the query.
Part of #1833 (closed) (the method is used by dependent branches).