select connection_id() into @conid; select thread_id from performance_schema.threads where PROCESSLIST_ID = @conid into @tid; set @a=1; set @b=2; set @c=3; ==================================================================== Testing index for columns THREAD_ID, VARIABLE_NAME ==================================================================== ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE user_variables_by_thread NULL ref PRIMARY PRIMARY 8 const # 100.00 Using where ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID > "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE user_variables_by_thread NULL ALL PRIMARY NULL NULL NULL # 33.33 Using where ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID < "2"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE user_variables_by_thread NULL ALL PRIMARY NULL NULL NULL # 33.33 Using where ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = @tid; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE user_variables_by_thread NULL ref PRIMARY PRIMARY 8 const # 100.00 Using where ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = "impossible" and VARIABLE_NAME = "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL no matching row in const table ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = @tid and VARIABLE_NAME = "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL no matching row in const table ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = @tid and VARIABLE_NAME > "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE user_variables_by_thread NULL ref PRIMARY PRIMARY 8 const # 33.33 Using where ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = @tid and VARIABLE_NAME < "2"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE user_variables_by_thread NULL ref PRIMARY PRIMARY 8 const # 33.33 Using where ############ Explain for Query #################################### explain select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = @tid and VARIABLE_NAME = "a"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE user_variables_by_thread NULL const PRIMARY PRIMARY 266 const,const # 100.00 NULL ############# Explain End ######################################### flush status; select VARIABLE_VALUE from performance_schema.user_variables_by_thread where THREAD_ID = @tid and VARIABLE_NAME = "a"; VARIABLE_VALUE # OK: handler_read_key incremented