| 16350 | */ |
| 16351 | |
| 16352 | static bool |
| 16353 | make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) |
| 16354 | { |
| 16355 | JOIN_TAB *tab; |
| 16356 | uint i; |
| 16357 | DBUG_ENTER("make_join_readinfo"); |
| 16358 | |
| 16359 | Json_writer_object trace_wrapper(join->thd); |
| 16360 | Json_writer_array trace_arr(join->thd, "make_join_readinfo"); |
| 16361 | |
| 16362 | bool statistics= MY_TEST(!(join->select_options & SELECT_DESCRIBE)); |
| 16363 | bool sorted= 1; |
| 16364 | |
| 16365 | join->complex_firstmatch_tables= table_map(0); |
| 16366 | |
| 16367 | if (!join->select_lex->sj_nests.is_empty() && |
| 16368 | setup_semijoin_dups_elimination(join, options, no_jbuf_after)) |
| 16369 | DBUG_RETURN(TRUE); /* purecov: inspected */ |
| 16370 | |
| 16371 | /* For const tables, set partial_join_cardinality to 1. */ |
| 16372 | for (tab= join->join_tab; tab != join->join_tab + join->const_tables; tab++) |
| 16373 | tab->partial_join_cardinality= 1; |
| 16374 | |
| 16375 | JOIN_TAB *prev_tab= NULL; |
| 16376 | i= join->const_tables; |
| 16377 | for (tab= first_linear_tab(join, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); |
| 16378 | tab; |
| 16379 | prev_tab=tab, tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS)) |
| 16380 | { |
| 16381 | /* |
| 16382 | The approximation below for partial join cardinality is not good because |
| 16383 | - it does not take into account some pushdown predicates |
| 16384 | - it does not differentiate between inner joins, outer joins and |
| 16385 | semi-joins. |
| 16386 | Later it should be improved. |
| 16387 | */ |
| 16388 | |
| 16389 | if (tab->bush_root_tab && tab->bush_root_tab->bush_children->start == tab) |
| 16390 | prev_tab= NULL; |
| 16391 | DBUG_ASSERT(tab->bush_children || |
| 16392 | tab->table == join->best_positions[i].table->table); |
| 16393 | |
| 16394 | tab->partial_join_cardinality= join->best_positions[i].records_read * |
| 16395 | (prev_tab ? |
| 16396 | prev_tab->partial_join_cardinality : 1); |
| 16397 | if (!tab->bush_children) |
| 16398 | i++; |
| 16399 | } |
| 16400 | |
| 16401 | check_join_cache_usage_for_tables(join, options, no_jbuf_after); |
| 16402 | |
| 16403 | JOIN_TAB *first_tab; |
| 16404 | for (tab= first_tab= first_linear_tab(join, |
| 16405 | WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); |
| 16406 | tab; |
| 16407 | tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS)) |
| 16408 | { |
| 16409 | if (tab->bush_children) |
no test coverage detected