MySQL - does log record the deleted query of a parent-child table?

63 Views Asked by At

In my MySQL db are 2 tables: Parent and Child. (a field in Child refers to the id field in Parent)

Sometimes I got a record in Child deleted.

Does log-enabling (in /etc/mysql/my.cnf) help me observe what actually causes my Child record deleted?

One more concern:

In /etc/mysql/my.cnf, there is this warning:

Be aware that this log type is a performance killer.

How bad could it be?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

First: As you mentioned in your question: a field in Child refers to the id field in Parent, this means if you delete your parent, the associated child also gets deleted if that field is configured as foreign key.

Does log-enabling (in /etc/mysql/my.cnf) help me observe what actually causes my Child record deleted?,

Yes it is possible to log your query. It's up to you however to interpret from logs what query caused the delete.

How bad could it be?

It surely decreases the performance, but it totally depends on the amount of data queried and logged and your own server/pc architecture.

There is a nice statistical blog that explains performance degrade:

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%.

You can read that blog here.