简体   繁体   中英

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

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM