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

Optimize parseTimeUnit() for date expressions

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • QE 2022-07-11, QE 2022-07-25, QE 2022-08-08

      The parseTimeUnit() is an expensive operation, which is on the hot path for ExpressionDateDiff and ExpressionDateTrunc. In most queries the time unit is specified as a constant in the query. So the parseTimeUnit() can be invoked during the Expression::optimize() and stored as a member variable. Additionally, the parseTimeUnit() does an extra lookup in the timeUnitNameToTimeUnitMap hash map, which can be avoided.

        1. out.svg
          131 kB

            Assignee:
            alberto.massari@mongodb.com Alberto Massari
            Reporter:
            rui.liu@mongodb.com Rui Liu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: