MySQL - 日志是否记录父子table删除的查询?
MySQL - does log record the deleted query of a parent-child table?
在我的 MySQL 数据库中有 2 个表:Parent
和 Child
。 (Child
中的字段引用Parent
中的id
字段)
有时我在 Child
中删除了一条记录。
日志启用(在 /etc/mysql/my.cnf
中)是否帮助我观察导致我的 Child
记录被删除的真正原因?
还有一个问题:
在/etc/mysql/my.cnf
中,有这个警告:
Be aware that this log type is a performance killer.
能有多糟糕?
谢谢
首先:
正如您在问题中提到的:a field in Child refers to the id field in Parent
,这意味着如果您删除 parent
,关联的 child
也会被删除 如果该字段配置为外键 .
log-enabling(在/etc/mysql/my.cnf)能帮我观察到底是什么导致我的Child记录被删除吗?,
是的,可以记录您的查询。然而,由您决定从日志中解释是什么查询导致了删除。
能有多糟糕?
它肯定会降低性能,但这完全取决于查询和记录的数据量以及您自己的 server/pc 架构。
有一个很好的统计博客解释了性能下降:
Using the general log enabled (general_log = ON) and the log destination is file (log_output = FILE) decreased the throughput by 13.4% and increased the response time by 17.5%.
您可以阅读该博客 here。
在我的 MySQL 数据库中有 2 个表:Parent
和 Child
。 (Child
中的字段引用Parent
中的id
字段)
有时我在 Child
中删除了一条记录。
日志启用(在 /etc/mysql/my.cnf
中)是否帮助我观察导致我的 Child
记录被删除的真正原因?
还有一个问题:
在/etc/mysql/my.cnf
中,有这个警告:
Be aware that this log type is a performance killer.
能有多糟糕?
谢谢
首先:
正如您在问题中提到的:a field in Child refers to the id field in Parent
,这意味着如果您删除 parent
,关联的 child
也会被删除 如果该字段配置为外键 .
log-enabling(在/etc/mysql/my.cnf)能帮我观察到底是什么导致我的Child记录被删除吗?,
是的,可以记录您的查询。然而,由您决定从日志中解释是什么查询导致了删除。
能有多糟糕?
它肯定会降低性能,但这完全取决于查询和记录的数据量以及您自己的 server/pc 架构。
有一个很好的统计博客解释了性能下降:
Using the general log enabled (general_log = ON) and the log destination is file (log_output = FILE) decreased the throughput by 13.4% and increased the response time by 17.5%.
您可以阅读该博客 here。