Home > Database > Mysql Tutorial > body text

What is the impact of long transactions in Mysql

WBOY
Release: 2023-06-03 15:13:04
forward
1718 people have browsed it

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;
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!