Hi All, this document deals with how to check the number of threads connected to MySQL.

Mysql is a single process application which supports multithreading. For each and every connections a thread is created in MySQL server. Thread gets destroy once the operation is done in MySQL server which leads to closing the connection to MySQL server.

you can use SHOW PROCESSLIST command in MySQL to see about what’s going on in your SQL server.

This is the sample output of the above command.

MariaDB [(none)]> SHOW PROCESSLIST;
+-----+-------------+--------------------+------+---------+------+--------------------------+------------------+----------+
| Id  | User        | Host               | db   | Command | Time | State                    | Info             | Progress |
+-----+-------------+--------------------+------+---------+------+--------------------------+------------------+----------+
|   1 | system user |                    | NULL | Daemon  | NULL | InnoDB purge coordinator | NULL             |    0.000 |
|   2 | system user |                    | NULL | Daemon  | NULL | InnoDB purge worker      | NULL             |    0.000 |
|   4 | system user |                    | NULL | Daemon  | NULL | InnoDB purge worker      | NULL             |    0.000 |
|   3 | system user |                    | NULL | Daemon  | NULL | InnoDB purge worker      | NULL             |    0.000 |
|   5 | system user |                    | NULL | Daemon  | NULL | InnoDB shutdown handler  | NULL             |    0.000 |

Use the below command to see how many threads are connected. This will be very useful when you undergo with the performance test.


MariaDB [(none)]> SHOW STATUS WHERE `variable_name` = 'Threads_connected';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Threads_connected | 55    |
+-------------------+-------+
1 row in set (0.25 sec)

 

© 2018, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points
Categories: database

Prabhin Prabharkaran

He is Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!!

Leave a Reply

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.