• Sergey Petrunya's avatar
    Backport of (see below) + temporary measures to make SJ-Materialization work with join buffering. · d2cbb104
    Sergey Petrunya authored
    Date: Mon, 01 Nov 2010 15:15:25 -0000
    3272 Roy Lyseng        2010-11-01
    Bug#52068: Optimizer generates invalid semijoin materialization plan
    
    When MaterializeScan semijoin strategy was used and there were one
    or more outer dependent tables before the semijoin tables, the scan
    over the materialized table was not properly reset for each row of
    the prefix outer tables.
    
    Example: suppose we have a join order:
    
      ot1 SJ-Mat-Scan(it2 it3)  ot4
    
    Notice that this is called a MaterializeScan, even though there is an
    outer table ahead of the materialized tables. Usually a MaterializeScan
    has the outer tables after the materialized table, but this is
    a special (but legal) case with outer dependent tables both before and
    after the materialized table.
    
    For each qualifying row from ot1, a new scan over the materialized
    table must be set up. The code failed to do that, so all scans after
    the first one returned zero rows from the materialized table.
    d2cbb104
subselect_no_semijoin.result 173 KB