6.4 线程结构
6.4.1 后台线程
MySQL是一个单进程多线程架构的数据库管理系统,所以当MySQL实例启动之后,会存在众多的线程来做各种各样的事情。我们可以通过performance_schema.threads表查询到所有线程,包括后台线程和前台线程.
表查询到所有线程,包括后台线程和前台线程
1mysql> select name,count(*) from performance_schema.threads2where type='BACKGROUND' group by name;3mysql> select name , type , thread_id,processlist_id4from performance_schema.threads where type='BACKGROUND';
6.4.2 前台线程
前台线程其实就是通过TCP/IP 协议或客户端程序创建的线程,所以包括了与主备复制相关的线程和用户创建的连接线程。跟 MySQL 后台线程类似,我们也可以通过 performance_schema.threads 表来查询 MySQL 中有哪些前台线程。
1mysql> select * from performance_schema.threads;2mysql> select name,type,thread_id,processlist_id3from performance_schema.threads where type='FOREGROUND';4mysql> show processlist;