Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-92

Optimize repeated queries

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      We have many cases where queries are being repeatedly re-run. It happens with our live queries in the bindings, where they are lazily re-run on access if the Realm has changed, and with the new async queries we will have them running repeatedly in background threads in response to any change in the Realm.

      This obviously consumes quite a bit of resources (and time), and in many (most?) cases it will not even be needed as the changes to Realm might not have affected the actual data being queried at all.

      Given the persistent tree structure of Realm, we could actually detect many of these cases very cheaply. If the query stored the top-ref of the tables involved in the query (this is actually the tricky part, since links can make a single query involve multiple tables), then we could just compare this to the current table top-refs, and if they are still the same, we know that the query result will be unchanged as well.

      We could even optimize this further by storing the top-refs for the individual columns involved in the query. That would allow us to avoid re-running the queries even if there has been updates to the table, s long as it does not hit the columns being queried.

      This is not a high performance task, but one I think could become relevant as more users start using the async queries.

            Assignee:
            Unassigned Unassigned
            Reporter:
            alexander.stigsen@mongodb.com Alexander Stigsen (Inactive)
            AD Core
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: