Why MySQL add one to the row count estimation when the table is empty in the left join situation?

  c++, mysql

when estimate the row count ,the MySQL would add one to the row count when the table is empty in the left join situation, From the comments the reason it that "The MySQL optimizer seems to assume in a left join that n_rows is an accurate estimate if it is zero. Of course, it is not, since we do not have any locks on the rows yet at this phase.", what does it means? any example can be used to explain it ? code url

    /*
    The MySQL optimizer seems to assume in a left join that n_rows
    is an accurate estimate if it is zero. Of course, it is not,
    since we do not have any locks on the rows yet at this phase.
    Since SHOW TABLE STATUS seems to call this function with the
    HA_STATUS_TIME flag set, while the left join optimizer does not
    set that flag, we add one to a zero value if the flag is not
    set. That way SHOW TABLE STATUS will show the best estimate,
    while the optimizer never sees the table empty.
    However, if it is internal temporary table used by optimizer,
    the count should be accurate */

    if (n_rows == 0 && !(flag & HA_STATUS_TIME)
              && table_share->table_category != TABLE_CATEGORY_TEMPORARY) {
        n_rows++;
    }

Source: Windows Questions C++

LEAVE A COMMENT