Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-90043

Extend oplog scan optimization to handle backwards scans

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization

      For certain queries against the oplog, we can create a bounded collection scan if the query contains a predicate on the `ts` field since we know that `ts` will be monotonically increasing. The conditions require that the scan direction is forward, however it's fairly common to use a {$sort: {$natural: -1}} combined with limit(1) to find the latest oplog entry which matches some predicate.

      For example, the following query

      oplog.find({ts: {$gt: <timestamp>}}).sort({$natural: -1}).limit(1)

      will scan the entire oplog even though it can stop at timestamp. There may also be an analogous optimization where the predicate is $lt and we can use the timestamp as a starting point for the backwards scan.

            Assignee:
            Unassigned Unassigned
            Reporter:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: