Currently the audit log SQL query to detect the remote changes is quite complex, with a lot of OR / AND clauses to filter the relevant events. Even with the right indexes on the database (especially on the event date, doc UUID, event category), this could lead to long running queries.
We could make this query faster without any regression in the global performances by removing the event clause and post-filtering the results in Java. Indeed:
- the query filters events within a date range and related to docs nested in the user's synchronization roots => the number of rows returned should be quite small
- we are probably interested in most of the events logged for documents, so post-filtering should be efficient (actually we probably want to have all the events and let the client decide of its impact on the synchronization process itself)