Class TransformPromoteTableEmpty

  • All Implemented Interfaces:
    Transform

    public class TransformPromoteTableEmpty
    extends TransformCopy
    Optimizer that ensures that table empty is promoted as high up a query as is possible

    table empty is an operator that may be introduced into the algebra by other optimizations and represents the case where the optimizer can a priori determine that some portion of a query will produce no results. The classic example of this are FILTER clauses that may be determined to always return false and thus negate the need to evaluate their inner operations.

    Other optimizers introduce table empty at the point in the query where they are optimizing, often its presence in a query may render a larger portion of even the entire query superfluous so this optimizer is designed to promote it up through the query as necessary.

    As detailed below this is not guaranteed to eliminate all portions of a query rather it aims to eliminate portions where not doing so can cause expensive and unnecessary evaluation to happen e.g. evaluating the left hand side of a join (which may itself be a deeply nested operator) only to join it with table empty and thus discard all the work that had been done.

    Table Empty Promotions

    The optimizer makes the following promotions:

    • Graph over table empty => table empty
    • Assign/Extend over table empty => table empty
    • Join where either side is table empty => table empty
    • Left Join:
      • If LHS is table empty => table empty
      • If RHS is table empty => LHS
    • Union:
      • If both sides are table empty => table empty
      • If one side is table empty => other side
    • Minus:
      • If LHS is table empty => table empty
      • If RHS is table empty => LHS

    All other operators are left untouched either because it cannot be promoted through them or because doing so has no clear benefit since applying them over table empty should be minimal work anyway.