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

Enable indexed plans for expressions with $$NOW, $$CLUSTER_TIME, and $$USER_ROLES

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • QE 2024-05-13

      This code from SERVER-74264 disabled constant folding for expressions involving $$NOW, $$CLUSTER_TIME, or $$USER_ROLES.  This prevents some relatively simple queries from being satisfied by an index.  For example:

      db.coll.find({"$expr": {"$lt": ["$_ts",

      {"$subtract": ["$$NOW",604800]}

      ]}})

      will lead to a collection scan even if there is an index on the _ts field.

      We should find a way to build an IXSCAN plan for such queries while still avoiding the plan cache bug fixed by SERVER-74264.

      Note that this was inspired by HELP-52526 for a query generated by online archive.

            Assignee:
            evan.bergeron@mongodb.com Evan Bergeron
            Reporter:
            steve.tarzia@mongodb.com Steve Tarzia
            Votes:
            0 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated: