> With per-message filtering this changes to something like this:
>
>  3. loop over the resultset and send all _allowed_ messages to the
> newly available resource
>  4. for each sent message, DELETE FROM offline_messages WHERE JID ==
> ${account_jid} and MESSAGEID == $(unique_message_id)
>
> This could be optimized somewhat, but would still be relatively complex.

This is a non-issue. The problem here is how expensive it is to find
each message to delete, but you have a list of IDs. You can avoid all
the overhead of multiple queries by sending a single SQL statement:

DELETE FROM offline_messages WHERE jid == ${account_id} and message_id
IN (@unique_message_ids)

This should probably be more efficient than the non-allow case,
because there are less messages to delete than the full list.

jack.

Reply via email to