When opening a group chat we check if all
participants are verified (which confers to the
chat verified status and a "✓ Verified" label in
the header) and we also check if any participants
have the "no longer verified" status so we can
warn you about potential misdeeds.
Previously, this was done by performing a select
statement for each participant twice (once for
"are all verified" and again for "is any
no-longer-verified").
This change uses a join in a select statement
instead to reduce the number of queries performed.
Given existing indexes in the DB this can be done
efficiently. Adding additional indexes does not
seem to help - or at least I wasn't able to get
sqlite to use them.
Since most chats are not verified, we use a LIMIT
clause when possible to allow the DB to stop
early, which should make queries even cheaper.