Internal Functions PS_CURRENT_THREAD_ID()  was added in MySQL 8.0.16. It may be used as a shortcut for invoking the sys  schema  ps_thread_id()  function with an argument of  NULL  or  CONNECTION_ID() . Given a connection ID, returns a  BIGINT UNSIGNED  value representing the Performance Schema thread ID assigned to the connection ID, or  NULL  if no thread ID exists for the connection ID. The latter can occur for threads that are not instrumented. The connection ID argument is a value of the type given in the  PROCESSLIST_ID  column of the Performance Schema  threads  table or the  Id  column of  SHOW PROCESSLIST  output. The thread ID return value is a value of the type given in the  THREAD_ID  column of Performance Schema tables. Performance Schema configuration affects  PS_THREAD_ID()  operation as follows. (These remarks also apply to  PS_CURRENT_THREAD_ID() .) PS_THREAD_ID()  was added in MySQL 8.0.16. It may be used instead of the  sys  schema ps_thread_id()  function, keeping in mind this difference: • PS_THREAD_ID( connection_id ) •Disabling the  thread_instrumentation  consumer disables statistics from being collected and aggregated at the thread level, but has no effect on  PS_THREAD_ID() . •If  performance_schema_max_thread_instances  is not 0, the Performance Schema allocates memory for thread statistics and assigns an internal ID to each thread for which instance memory is available. If there are threads for which instance memory is not available,  PS_THREAD_ID()  returns NULL ; in this case,  Performance_schema_thread_instances_lost  is nonzero. •If  performance_schema_max_thread_instances  is 0, the Performance Schema allocates no thread memory and  PS_THREAD_ID()  returns  NULL . •If the Performance Schema itself is disabled,  PS_THREAD_ID()  produces an error. •With an argument of  NULL ,  sys.ps_thread_id()  returns the thread ID for the current connection, whereas  PS_THREAD_ID()  returns  NULL . To obtain the current connection thread ID, use PS_CURRENT_THREAD_ID()  instead. mysql>  SELECT PS_THREAD_ID(6); +-----------------+ | PS_THREAD_ID(6) | +-----------------+ | 45 | +-----------------+ Name Description Introduced CAN_ACCESS_COLUMN() Internal use only CAN_ACCESS_DATABASE() Internal use only CAN_ACCESS_TABLE() Internal use only CAN_ACCESS_USER() Internal use only 8.0.22 CAN_ACCESS_VIEW() Internal use only Table 12.28 Internal Functions 12.23 Internal Functions 2436