Link to home
Start Free TrialLog in
Avatar of Software Software
Software SoftwareFlag for Austria

asked on

Mysql: Show all active transactions

I need a sql command which shows me all active transactions
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Assuming INNODB:  Take a look at the INNODB_TRX Table in the docs:
https://dev.mysql.com/doc/refman/8.0/en/innodb-trx-table.html

The INNODB_TRX table providesinformation about every transaction (excluding read-onlytransactions) currently executing inside InnoDB, including whether the transaction iswaiting for a lock, when the transaction started, and the SQLstatement the transaction is executing, if any.
mytop is a handy tool, packaged for every Linux Distro.

This tool instantly shows long running SQL statements.

Likely there are Windows ports also, if you run Windows.
Hi,

You can also look at the threads by querying the INFORMATION_SCHEMA.PROCESSLIST table.
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST

Open in new window

and if you have the performance_schema turned on you could use that to query and investigate performance problems.

https://dev.mysql.com/doc/refman/8.0/en/performance-schema.html
https://dev.mysql.com/doc/refman/8.0/en/information-schema.html

Regards,
    Tomas Helgi
Show processlist

Show full processlist

I used to handle queries timeout through comments stuck in the query anx a small daemon
Wouldn't the processlist show connections not just transactions?
Yes, you'd need a trivial filter.

Innodb also has tools that display transactions in the engine but these require some parsing. Innotop gives a decent view of such transactions
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.