create user foo@localhost; grant ALL on *.* to foo@localhost; truncate table performance_schema.events_transactions_history; # Connection 1 select connection_id() into @conid; start transaction; rollback; # Default connection ==================================================================== Testing index for columns THREAD_ID, EVENT_ID ==================================================================== ############ Explain for Query #################################### explain select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE events_transactions_history NULL ref PRIMARY PRIMARY 8 const # 100.00 Using where ############ Explain for Query #################################### explain select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID > "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE events_transactions_history NULL ALL PRIMARY NULL NULL NULL # 33.33 Using where ############ Explain for Query #################################### explain select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID < "2"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE events_transactions_history NULL ALL PRIMARY NULL NULL NULL # 33.33 Using where ############ Explain for Query #################################### explain select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = @tid; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE events_transactions_history NULL ref PRIMARY PRIMARY 8 const # 100.00 Using where ############ Explain for Query #################################### explain select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = "impossible" and EVENT_ID = "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 END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = @tid and EVENT_ID = "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 END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = @tid and EVENT_ID > "impossible"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE events_transactions_history NULL ref PRIMARY PRIMARY 8 const # 33.33 Using where ############ Explain for Query #################################### explain select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = @tid and EVENT_ID < "2"; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE events_transactions_history NULL ref PRIMARY PRIMARY 8 const # 33.33 Using where ############ Explain for Query #################################### explain select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = @tid and EVENT_ID = @eid; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE events_transactions_history NULL const PRIMARY PRIMARY 16 const,const # 100.00 NULL ############# Explain End ######################################### flush status; select END_EVENT_ID from performance_schema.events_transactions_history where THREAD_ID = @tid and EVENT_ID = @eid; END_EVENT_ID # OK: handler_read_key incremented commit; drop user foo@localhost;