| 2211 | */ |
| 2212 | |
| 2213 | int |
| 2214 | JOIN::optimize_inner() |
| 2215 | { |
| 2216 | DBUG_ENTER("JOIN::optimize_inner"); |
| 2217 | subq_exit_fl= false; |
| 2218 | best_read= 0.0; |
| 2219 | |
| 2220 | DEBUG_SYNC(thd, "before_join_optimize"); |
| 2221 | THD_STAGE_INFO(thd, stage_optimizing); |
| 2222 | #ifndef DBUG_OFF |
| 2223 | dbug_join_tab_array_size= 0; |
| 2224 | #endif |
| 2225 | |
| 2226 | // rownum used somewhere in query, no limits and it is derived |
| 2227 | if (unlikely(thd->lex->with_rownum && |
| 2228 | select_lex->first_cond_optimization && |
| 2229 | select_lex->master_unit()->derived)) |
| 2230 | optimize_upper_rownum_func(); |
| 2231 | |
| 2232 | do_send_rows = (unit->lim.get_select_limit()) ? 1 : 0; |
| 2233 | |
| 2234 | set_allowed_join_cache_types(); |
| 2235 | need_distinct= TRUE; |
| 2236 | |
| 2237 | Json_writer_object trace_wrapper(thd); |
| 2238 | Json_writer_object trace_prepare(thd, "join_optimization"); |
| 2239 | trace_prepare.add_select_number(select_lex->select_number); |
| 2240 | Json_writer_array trace_steps(thd, "steps"); |
| 2241 | |
| 2242 | if (select_lex->opt_hints_qb) |
| 2243 | select_lex->opt_hints_qb->trace_hints(thd); |
| 2244 | |
| 2245 | /* |
| 2246 | Needed in case optimizer short-cuts, |
| 2247 | set properly in make_aggr_tables_info() |
| 2248 | */ |
| 2249 | fields= &select_lex->item_list; |
| 2250 | |
| 2251 | if (select_lex->first_cond_optimization) |
| 2252 | { |
| 2253 | //Do it only for the first execution |
| 2254 | /* Merge all mergeable derived tables/views in this SELECT. */ |
| 2255 | if (select_lex->handle_derived(thd->lex, DT_MERGE)) |
| 2256 | DBUG_RETURN(TRUE); |
| 2257 | table_count= select_lex->leaf_tables.elements; |
| 2258 | } |
| 2259 | |
| 2260 | if (select_lex->first_cond_optimization && |
| 2261 | transform_in_predicates_into_in_subq(thd)) |
| 2262 | DBUG_RETURN(1); |
| 2263 | |
| 2264 | /* |
| 2265 | Update used tables after all handling derived table procedures |
| 2266 | After this call, select_lex->select_list_tables contains the table |
| 2267 | bits of all items in the select list (but not bits from WHERE clause or |
| 2268 | other items). |
| 2269 | */ |
| 2270 | select_lex->update_used_tables(); |
nothing calls this directly
no test coverage detected