Skip to content

Instantly share code, notes, and snippets.

@NeilMasters
Created April 4, 2024 17:33
Show Gist options
  • Save NeilMasters/5d053bd34cffc58edf08bac673a1d706 to your computer and use it in GitHub Desktop.
Save NeilMasters/5d053bd34cffc58edf08bac673a1d706 to your computer and use it in GitHub Desktop.
List all long running transactions on a mysql database server
SELECT
a.trx_id, a.trx_state, a.trx_started,
TIMESTAMPDIFF(SECOND,a.trx_started, now()) as "Seconds Transaction Has Been Open",
a.trx_rows_modified,
b.USER, b.host, b.db, b.command, b.time, b.state
FROM
information_schema.innodb_trx a
INNER JOIN
information_schema.processlist b ON b.id = a.trx_mysql_thread_id
ORDER BY
trx_started;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment