mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-7943 - pthread_getspecific() takes 0.76% in OLTP RO
Pass THD to find_all_keys() and Item_equal::Item_equal(). In MRR use table->in_use instead of current_thd. This reduces number of pthread_getspecific() calls from 354 to 320.
This commit is contained in:
@ -50,7 +50,7 @@ if (my_b_write((file),(uchar*) (from),param->ref_length)) \
|
||||
|
||||
static uchar *read_buffpek_from_file(IO_CACHE *buffer_file, uint count,
|
||||
uchar *buf);
|
||||
static ha_rows find_all_keys(Sort_param *param,SQL_SELECT *select,
|
||||
static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
||||
Filesort_info *fs_info,
|
||||
IO_CACHE *buffer_file,
|
||||
IO_CACHE *tempfile,
|
||||
@ -294,7 +294,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
|
||||
param.sort_form= table;
|
||||
param.end=(param.local_sortorder=sortorder)+s_length;
|
||||
num_rows= find_all_keys(¶m, select,
|
||||
num_rows= find_all_keys(thd, ¶m, select,
|
||||
&table_sort,
|
||||
&buffpek_pointers,
|
||||
&tempfile,
|
||||
@ -667,7 +667,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
|
||||
HA_POS_ERROR on error.
|
||||
*/
|
||||
|
||||
static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select,
|
||||
static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
||||
Filesort_info *fs_info,
|
||||
IO_CACHE *buffpek_pointers,
|
||||
IO_CACHE *tempfile,
|
||||
@ -679,7 +679,6 @@ static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select,
|
||||
uchar *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH];
|
||||
my_off_t record;
|
||||
TABLE *sort_form;
|
||||
THD *thd= current_thd;
|
||||
handler *file;
|
||||
MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set;
|
||||
|
||||
|
@ -5628,14 +5628,14 @@ Item *Item_bool_rowready_func2::negated_item()
|
||||
of the type Item_field or Item_direct_view_ref(Item_field).
|
||||
*/
|
||||
|
||||
Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item)
|
||||
Item_equal::Item_equal(THD *thd_arg, Item *f1, Item *f2, bool with_const_item)
|
||||
: Item_bool_func(), eval_item(0), cond_false(0), cond_true(0),
|
||||
context_field(NULL), link_equal_fields(FALSE)
|
||||
{
|
||||
const_item_cache= 0;
|
||||
with_const= with_const_item;
|
||||
equal_items.push_back(f1);
|
||||
equal_items.push_back(f2);
|
||||
equal_items.push_back(f1, thd_arg->mem_root);
|
||||
equal_items.push_back(f2, thd_arg->mem_root);
|
||||
compare_as_dates= with_const_item && f2->cmp_type() == TIME_RESULT;
|
||||
upper_levels= NULL;
|
||||
sargable= TRUE;
|
||||
@ -5654,7 +5654,7 @@ Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item)
|
||||
outer join).
|
||||
*/
|
||||
|
||||
Item_equal::Item_equal(Item_equal *item_equal)
|
||||
Item_equal::Item_equal(THD *thd_arg, Item_equal *item_equal)
|
||||
: Item_bool_func(), eval_item(0), cond_false(0), cond_true(0),
|
||||
context_field(NULL), link_equal_fields(FALSE)
|
||||
{
|
||||
@ -5663,7 +5663,7 @@ Item_equal::Item_equal(Item_equal *item_equal)
|
||||
Item *item;
|
||||
while ((item= li++))
|
||||
{
|
||||
equal_items.push_back(item);
|
||||
equal_items.push_back(item, thd_arg->mem_root);
|
||||
}
|
||||
with_const= item_equal->with_const;
|
||||
compare_as_dates= item_equal->compare_as_dates;
|
||||
|
@ -1904,12 +1904,8 @@ public:
|
||||
|
||||
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
|
||||
|
||||
inline Item_equal()
|
||||
: Item_bool_func(), with_const(FALSE), eval_item(0), cond_false(0),
|
||||
context_field(NULL)
|
||||
{ const_item_cache=0; sargable= TRUE; }
|
||||
Item_equal(Item *f1, Item *f2, bool with_const_item);
|
||||
Item_equal(Item_equal *item_equal);
|
||||
Item_equal(THD *thd_arg, Item *f1, Item *f2, bool with_const_item);
|
||||
Item_equal(THD *thd_arg, Item_equal *item_equal);
|
||||
/* Currently the const item is always the first in the list of equal items */
|
||||
inline Item* get_const() { return with_const ? equal_items.head() : NULL; }
|
||||
void add_const(THD *thd, Item *c, Item *f = NULL);
|
||||
|
@ -62,7 +62,7 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
|
||||
range_seq_t seq_it;
|
||||
ha_rows rows, total_rows= 0;
|
||||
uint n_ranges=0;
|
||||
THD *thd= current_thd;
|
||||
THD *thd= table->in_use;
|
||||
|
||||
/* Default MRR implementation doesn't need buffer */
|
||||
*bufsz= 0;
|
||||
@ -814,7 +814,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
|
||||
void *seq_init_param, uint n_ranges, uint mode,
|
||||
HANDLER_BUFFER *buf)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
THD *thd= h_arg->get_table()->in_use;
|
||||
int res;
|
||||
Key_parameters keypar;
|
||||
uint UNINIT_VAR(key_buff_elem_size); /* set/used when do_sort_keys==TRUE */
|
||||
@ -1573,7 +1573,7 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags,
|
||||
{
|
||||
Cost_estimate dsmrr_cost;
|
||||
bool res;
|
||||
THD *thd= current_thd;
|
||||
THD *thd= primary_file->get_table()->in_use;
|
||||
TABLE_SHARE *share= primary_file->get_table_share();
|
||||
|
||||
bool doing_cpk_scan= check_cpk_scan(thd, share, keyno, *flags);
|
||||
|
@ -12502,14 +12502,14 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item,
|
||||
if (left_copyfl)
|
||||
{
|
||||
/* left_item_equal of an upper level contains left_item */
|
||||
left_item_equal= new (thd->mem_root) Item_equal(left_item_equal);
|
||||
left_item_equal= new (thd->mem_root) Item_equal(thd, left_item_equal);
|
||||
left_item_equal->set_context_field(((Item_field*) left_item));
|
||||
cond_equal->current_level.push_back(left_item_equal);
|
||||
}
|
||||
if (right_copyfl)
|
||||
{
|
||||
/* right_item_equal of an upper level contains right_item */
|
||||
right_item_equal= new (thd->mem_root) Item_equal(right_item_equal);
|
||||
right_item_equal= new (thd->mem_root) Item_equal(thd, right_item_equal);
|
||||
right_item_equal->set_context_field(((Item_field*) right_item));
|
||||
cond_equal->current_level.push_back(right_item_equal);
|
||||
}
|
||||
@ -12537,7 +12537,8 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item,
|
||||
else
|
||||
{
|
||||
/* None of the fields was found in multiple equalities */
|
||||
Item_equal *item_equal= new (thd->mem_root) Item_equal(orig_left_item,
|
||||
Item_equal *item_equal= new (thd->mem_root) Item_equal(thd,
|
||||
orig_left_item,
|
||||
orig_right_item,
|
||||
FALSE);
|
||||
item_equal->set_context_field((Item_field*)left_item);
|
||||
@ -12596,7 +12597,7 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item,
|
||||
field_item->field, ©fl);
|
||||
if (copyfl)
|
||||
{
|
||||
item_equal= new (thd->mem_root) Item_equal(item_equal);
|
||||
item_equal= new (thd->mem_root) Item_equal(thd, item_equal);
|
||||
cond_equal->current_level.push_back(item_equal);
|
||||
item_equal->set_context_field(field_item);
|
||||
}
|
||||
@ -12611,8 +12612,8 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item,
|
||||
}
|
||||
else
|
||||
{
|
||||
item_equal= new (thd->mem_root) Item_equal(const_item, orig_field_item,
|
||||
TRUE);
|
||||
item_equal= new (thd->mem_root) Item_equal(thd, const_item,
|
||||
orig_field_item, TRUE);
|
||||
item_equal->set_context_field(field_item);
|
||||
cond_equal->current_level.push_back(item_equal, thd->mem_root);
|
||||
}
|
||||
|
Reference in New Issue
Block a user