1. Long transactions mean that there will be a very old transaction view in the system. Rollback records should be kept until this transaction is committed, which will result in a large amount of storage space.
2. Long transactions will also occupy lock resources and may drag down the database.
Example
SELECT ps.id 'PROCESS ID', ps.USER, ps.HOST, esh.EVENT_ID, trx.trx_started, esh.event_name 'EVENT NAME', esh.sql_text 'SQL', ps.time FROM performance_schema.events_statements_history esh JOIN performance_schema.threads th ON esh.thread_id = th.thread_id JOIN information_schema.PROCESSLIST ps ON ps.id = th.processlist_id LEFT JOIN information_schema.innodb_trx trx ON trx.trx_mysql_thread_id = ps.id WHERE trx.trx_id IS NOT NULL AND ps.USER != 'SYSTEM_USER' AND ps.id = 进程ID ORDER BY esh.EVENT_ID;
The above is the detailed content of What is the impact of long transactions in Mysql. For more information, please follow other related articles on the PHP Chinese website!