Skip to content

Commit

Permalink
[Optimization] Remove redundant pages allocations and frees
Browse files Browse the repository at this point in the history
  • Loading branch information
yongxin-xu committed Dec 2, 2020
1 parent 58e2751 commit 4c10388
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier, bool skip_global_sys_var_lock)
spider_slow_query_num = 0;
spider_current_partition_num = 0;
spider_features_type = 0;
spider_const_index_read = FALSE;
kill_self = FALSE;

file_id = 0;
Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,7 @@ class THD :public Statement,
ulong current_global_server_version;
bool is_support_ddl_by_ctl; // equal to tdbctl_is_ddl_by_ctl(thd,lex)
bool do_ddl_by_ctl; // must do tcadmin_execute_command
bool spider_const_index_read; // const or system join type in spider

// Process indicator
struct {
Expand Down
1 change: 1 addition & 0 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7014,6 +7014,7 @@ void THD::reset_for_next_command(bool do_clear_error) {
thd->spider_current_partition_num = 0;
thd->spider_features_type = 0;
thd->current_global_server_version = get_modify_server_version();
thd->spider_const_index_read = FALSE;

DBUG_PRINT("debug", ("is_current_stmt_binlog_format_row(): %d",
is_current_stmt_binlog_format_row()));
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17571,6 +17571,8 @@ static int join_read_const(JOIN_TAB *tab) {
if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
error = HA_ERR_KEY_NOT_FOUND;
else {
if (table->file->is_spider_storage_engine())
tab->join->thd->spider_const_index_read = TRUE;
error = table->file->ha_index_read_idx_map(
table->record[0], tab->ref.key, (uchar *)tab->ref.key_buff,
make_prev_keypart_map(tab->ref.key_parts), HA_READ_KEY_EXACT);
Expand Down
15 changes: 10 additions & 5 deletions storage/spider/spd_db_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3034,11 +3034,16 @@ int spider_db_store_result(ha_spider *spider, int link_idx, TABLE *table) {
SPIDER_DB_ROW *tmp_row;
uint field_count = current->result->num_fields();
SPIDER_POSITION *position;
longlong page_size =
!result_list->quick_page_size ||
result_list->limit_num < result_list->quick_page_size
? result_list->limit_num
: result_list->quick_page_size;
longlong page_size = 0LL;
if (thd->spider_const_index_read) {
/* only one row for const index read */
page_size = 1;
} else {
page_size = !result_list->quick_page_size ||
result_list->limit_num < result_list->quick_page_size
? result_list->limit_num
: result_list->quick_page_size;
}
int roop_count = 0;
current->field_count = field_count;
if (!(position = (SPIDER_POSITION *)spider_bulk_malloc(
Expand Down

0 comments on commit 4c10388

Please sign in to comment.