-
Roy Lyseng authored
The problem statement is a multi-table UPDATE statement, with an updated table that is joined to a join of two tables, enclosed in a derived table. In 5.6, the derived table was materialized into a temporary table, and the join was optimized properly. In 5.7, the derived table is still materialized, but it is not optimized, it performs as if a STRAIGHT_JOIN option has been added to the query block. A multi-table UPDATE statement does not allow semi-joined subqueries, thus the option SELECT_STRAIGHT_JOIN is added when optimizing subqueries. However, this option also affects join optimization, so in effect this means adding the STRAIGHT_JOIN option to the derived table subquery. Thus, the join is performed in a non-optimal way. The solution is to set the flag semijoin_disallowed for all query blocks of the derived table to trigger no semi-join transformation for this case. The SELECT_STRAIGHT_JOIN option is kept as-is, thus explicitly specifying the STRAIGHT_JOIN in either the parent or the child query block will still prevent semi-join transformation. Reviewed by: Guilhem Bichot <guilhem.bichot@oracle.com>
Roy Lyseng authoredThe problem statement is a multi-table UPDATE statement, with an updated table that is joined to a join of two tables, enclosed in a derived table. In 5.6, the derived table was materialized into a temporary table, and the join was optimized properly. In 5.7, the derived table is still materialized, but it is not optimized, it performs as if a STRAIGHT_JOIN option has been added to the query block. A multi-table UPDATE statement does not allow semi-joined subqueries, thus the option SELECT_STRAIGHT_JOIN is added when optimizing subqueries. However, this option also affects join optimization, so in effect this means adding the STRAIGHT_JOIN option to the derived table subquery. Thus, the join is performed in a non-optimal way. The solution is to set the flag semijoin_disallowed for all query blocks of the derived table to trigger no semi-join transformation for this case. The SELECT_STRAIGHT_JOIN option is kept as-is, thus explicitly specifying the STRAIGHT_JOIN in either the parent or the child query block will still prevent semi-join transformation. Reviewed by: Guilhem Bichot <guilhem.bichot@oracle.com>
Loading