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

Incorrect selectivity in explain for complex physical plans

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

      The implementation of SERVER-83441 introduces a new way to construct a physical plan from a FilterNode when the FilterNode is directly on top of a ScanNode. In this case, similar to the approach in the implementer for SargableNode, the FilterNode implementer creates a complex physical plan consisting directly of a FilterNode on top of a PhysicalScanNode.

      The selectivities of both physical nodes computed during their creation are correct, however the infrastructure in the optimizer that is supposed to pass this information to explain is not designed to do this correctly. The result is that explain shows the same CE for the PhysicalScanNode as the one of the FilterNode. Apparently explain picks the selectivity for the whole group instead of the specific per-node selectivity.

      As david.percy@mongodb.com said:

      it seems like there isn’t a quick fix for this.  It’s a bug in these interfaces: * NodeToGroupPropsMap is a confusing mixture of properties used for different purposes

      • explain wants to show per-physical-node properties
      • takes “group props” and displays it per-node: very misleading
      • plan extraction does not return per-node properties
      • the memo only record properties at group boundaries
      • implementers only return properties at group boundaries

      I think the solution is to change explain to only print properties at a group boundary.  And that seems unrelated to your work avoiding Sargable node.

       
      There are at least two possible approaches: * Extend/improve the optimizer logic around how node properties are propagated to explan, and make explain pick the correct properties of each node.

      • Impose a limitation that physical rewrites can only produce one physical node per logical node, and reimplement SERVER-83441. This looks very limiting, and is less desirable.

       

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            timour.katchaounov@mongodb.com Timour Katchaounov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: