如何监控数据库事务?
我为薪资系统编写了一个网络应用程序,可以对 mysql 数据库执行(插入、更新、删除)操作。
我想知道
mysql数据库发生了多少事务?
在start_time和end_time期间mysql数据库发生了多少事务?
I have written a webapplication for payroll system which can do (insert,update,delete) to mysql database.
I want to know
how many transaction happened in mysql database ?
how many transaction happened in mysql database during start_time and end_time ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MySQL 有命令计数器。可以通过
SHOW GLOBAL STATUS LIKE "COM\_%"
查看它们。每次执行命令都会增加与其关联的计数器。与事务相关的计数器有Com_begin
、Com_commit
和Com_rollback
。另外,Uptime
是服务器启动后的秒数。读取并绘制这些值或其增量,即可得到您所需的信息。还有用于
Com_insert
、Com_update
、Com_delete
及其变体的计数器。您可能还想将它们绘制成图表。MySQL has command counters. They can be seen with
SHOW GLOBAL STATUS LIKE "COM\_%"
. Each execution of a command increments the counter associated with it. Transaction related counters areCom_begin
,Com_commit
andCom_rollback
. AlsoUptime
is the number of seconds since server start. Reading and graphing these values or their delta yields the information you ask for.There are also counters for
Com_insert
,Com_update
,Com_delete
and variations thereof. You might want to graph these as well.不确定这就是您正在寻找的答案 我听说以下 JDBC 记录器对于跟踪应用程序对数据库执行的操作非常有用。它应该显示您的应用程序在何处打开和提交事务。然后,您应该能够编写一些脚本来处理日志以确定事务数量。
它基本上位于您的应用程序之间以及真实数据库驱动程序。您将 log4jdbc 前缀添加到 JDBC URL。例如,如果您的正常 jdbc url 是
,那么您可以将其更改为:
Not sure this the answer you are looking for you I've heard that the following JDBC logger is very useful for tracking what an application is doing to a database. It should show where your application is opening and commiting transactions. You should then be able to write some scripts to process the logs to determine the number transactions.
It basically sits between your application and the real database driver. You add a log4jdbc prefix to your JDBC URL. For example, if your normal jdbc url is
then you would change it to: