diff options
author | Michael Widenius <monty@askmonty.org> | 2012-03-23 18:18:16 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2012-03-23 18:18:16 +0200 |
commit | 8e825a2249440e7df0fce0123f6d543b09b29194 (patch) | |
tree | eb3591d867f6b8fc81a8885c129f8a375af376bf /sql/sql_select.h | |
parent | de1765fb64dda7c610217c27a6012955f01d88e4 (diff) | |
download | mariadb-git-8e825a2249440e7df0fce0123f6d543b09b29194.tar.gz |
Fixes lp:941889 "JOIN constructors takes a long time in 5.3"
- Remove all references of MAX_TABLES from JOIN struct and make these dynamic
- Updated Join_plan_state to allocate just as many elements as it's needed
sql/opt_subselect.cc:
Optimized version of Join_plan_state
sql/sql_select.cc:
Set join->positions and join->best_positions dynamicly
Don't call update_virtual_fields() if table->vfield is not set.
sql/sql_select.h:
Remove all references of MAX_TABLES from JOIN struct and Join_plan_state and make these dynamic
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r-- | sql/sql_select.h | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h index a5fa59a070a..a5c0a797ed6 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -742,7 +742,7 @@ public: Information about a position of table within a join order. Used in join optimization. */ -typedef struct st_position +typedef struct st_position :public Sql_alloc { /* The table that's put into join order */ JOIN_TAB *table; @@ -844,23 +844,36 @@ protected: */ class Join_plan_state { public: - DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */ - POSITION best_positions[MAX_TABLES+1]; /* Copy of JOIN::best_positions */ + DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */ + POSITION *best_positions; /* Copy of JOIN::best_positions */ /* Copies of the JOIN_TAB::keyuse pointers for each JOIN_TAB. */ - KEYUSE *join_tab_keyuse[MAX_TABLES]; + KEYUSE **join_tab_keyuse; /* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */ - key_map join_tab_checked_keys[MAX_TABLES]; - SJ_MATERIALIZATION_INFO *sj_mat_info[MAX_TABLES]; + key_map *join_tab_checked_keys; + SJ_MATERIALIZATION_INFO **sj_mat_info; + my_bool error; public: - Join_plan_state() + Join_plan_state(uint tables) : error(0) { keyuse.elements= 0; keyuse.buffer= NULL; + best_positions= 0; /* To detect errors */ + error= my_multi_malloc(MYF(MY_WME), + &best_positions, + sizeof(*best_positions) * (tables + 1), + &join_tab_keyuse, + sizeof(*join_tab_keyuse) * tables, + &join_tab_checked_keys, + sizeof(*join_tab_checked_keys) * tables, + &sj_mat_info, + sizeof(sj_mat_info) * tables, + NullS) == 0; } Join_plan_state(JOIN *join); ~Join_plan_state() { delete_dynamic(&keyuse); + my_free(best_positions, MYF(0)); } }; @@ -961,7 +974,7 @@ public: */ ha_rows fetch_limit; /* Finally picked QEP. This is result of join optimization */ - POSITION best_positions[MAX_TABLES+1]; + POSITION *best_positions; /******* Join optimization state members start *******/ /* @@ -971,7 +984,7 @@ public: TABLE_LIST *emb_sjm_nest; /* Current join optimization state */ - POSITION positions[MAX_TABLES+1]; + POSITION *positions; /* Bitmap of nested joins embedding the position at the end of the current @@ -1241,6 +1254,7 @@ public: exec_const_cond= 0; group_optimized_away= 0; no_rows_in_result_called= 0; + positions= best_positions= 0; all_fields= fields_arg; if (&fields_list != &fields_arg) /* Avoid valgrind-warning */ |