Live data from Hacker News

MySQL foreign key cascade operations finally hit the binary log

readyset.io

11–20 of 28 posts

Re: MySQL foreign key cascade operations finally hit the binary log

#11
post #2

I always end up disabling bin log for single-db setups, and simlly run backup jobs. Using bin log drastically reduces performance. Am I crazy?

The performance impact depends substantially on whether you've configured it to fsync the binlog on every group commit.

Also, it's important to consider that replication and backups serve different purposes. Backups alone are insufficient for high availability, change data capture, point-in-time recovery / undoing a bad change, etc.

Re: MySQL foreign key cascade operations finally hit the binary log

#12

Earlier quoted context omitted.

They should have addressed it much earlier, but it makes way more sense in historical context: when MySQL added utf8 support in early 2003, the utf8 standard originally permitted up to 6 bytes per char at that time. This had excessive storage implications, and emoji weren't in widespread use at all at the time. 3 bytes were sufficient to store the majority of chars in use at that time, so that's what they went with.…

Your explanation makes it sound like an incredibly stupid decision. I imagine what you're getting at is that 3 bytes were/are sufficient for the basic multilingual plane, which is incidentally also what can be represented in a single utf-16 byte pair. So they imposed the same limitation as utf-16 had on utf-8. This would have seemed logical in a world where utf-16 was the default and utf-8 was some annoying exception…

OK, but that makes perfect sense given utf-16 was actually quite widespread in 2003! For example, Windows APIs, MS SQL Server, JavaScript (off the top of my head)... these all still primarily use utf-16 today even. And MySQL also supports utf-16 among many other charsets.

There wasn't a clear winner in utf-8 at the time, especially given its 6-byte-max representation back then. Memory and storage were a lot more limited.

And yes while 6 bytes was the maximum, a bunch of critical paths (e.g. sorting logic) in old MySQL required allocating a worst-case buffer size, so this would have been prohibitively expensive.

Re: MySQL foreign key cascade operations finally hit the binary log

#13
post #7
post #2

I always end up disabling bin log for single-db setups, and simlly run backup jobs. Using bin log drastically reduces performance. Am I crazy?

Turning it off cause you're not using it seems reasonable, but I'm surprised it has a big effect on performance. Sequential appends to a file are pretty easy as long as you're not doing so many writes per second that there's contention on the write.

Fsync

Re: MySQL foreign key cascade operations finally hit the binary log

#14
This is excellent. In the past when replicating via Debezium from a system making heavy use of cascade deletes I’ve had to write a layer that infers these deletes by introspecting the database schema, building a graph of all cascades (sometimes several layers) and identifying rows that should have corresponding delete records. These can then be excluded in whatever downstream system via an anti-join. It works but it will be better to not have to do that and instead have first class support for cascades.

Re: MySQL foreign key cascade operations finally hit the binary log

#15
post #7
post #2

I always end up disabling bin log for single-db setups, and simlly run backup jobs. Using bin log drastically reduces performance. Am I crazy?

Turning it off cause you're not using it seems reasonable, but I'm surprised it has a big effect on performance. Sequential appends to a file are pretty easy as long as you're not doing so many writes per second that there's contention on the write.

I am doing many writes inserts/updates per second.

Re: MySQL foreign key cascade operations finally hit the binary log

#16
post #4
post #2

I always end up disabling bin log for single-db setups, and simlly run backup jobs. Using bin log drastically reduces performance. Am I crazy?

I've used bin log for almost decades and never experienced a big performance impact. This even holds for write heavy MySQL instances in ancient times where servers had spinning disks.

Thinking back about it, I think the biggest issue was the size, not performance. For a write-intensive app, the bin long quickly got to tens of GBs and filled the entire disk, which was a problem when running the app on smaller VPSs.

Re: MySQL foreign key cascade operations finally hit the binary log

#17
post #7

Earlier quoted context omitted.

Turning it off cause you're not using it seems reasonable, but I'm surprised it has a big effect on performance. Sequential appends to a file are pretty easy as long as you're not doing so many writes per second that there's contention on the write.

Fsync

Do you mean fsync can lead ro poor performance?

Re: MySQL foreign key cascade operations finally hit the binary log

#18
post #2

I always end up disabling bin log for single-db setups, and simlly run backup jobs. Using bin log drastically reduces performance. Am I crazy?

The performance impact depends substantially on whether you've configured it to fsync the binlog on every group commit. Also, it's important to consider that replication and backups serve different purposes. Backups alone are insufficient for high availability, change data capture, point-in-time recovery / undoing a bad change, etc.

In my case it's for analytics, so I am ok with some data loss in case of a failure.

How do I set the fsync stuff? Does if have to be turned off?

Re: MySQL foreign key cascade operations finally hit the binary log

#19
post #18

Earlier quoted context omitted.

The performance impact depends substantially on whether you've configured it to fsync the binlog on every group commit. Also, it's important to consider that replication and backups serve different purposes. Backups alone are insufficient for high availability, change data capture, point-in-time recovery / undoing a bad change, etc.

In my case it's for analytics, so I am ok with some data loss in case of a failure. How do I set the fsync stuff? Does if have to be turned off?

The sync_binlog server variable controls this behavior. The default of 1 means to fsync every time, which is best for durability but worst for performance. See https://dev.mysql.com/doc/refman/8.4/en/replication-options-...

Re: MySQL foreign key cascade operations finally hit the binary log

#20
post #16
post #4

Earlier quoted context omitted.

I've used bin log for almost decades and never experienced a big performance impact. This even holds for write heavy MySQL instances in ancient times where servers had spinning disks.

Thinking back about it, I think the biggest issue was the size, not performance. For a write-intensive app, the bin long quickly got to tens of GBs and filled the entire disk, which was a problem when running the app on smaller VPSs.

You can tune binlog_expire_logs_seconds to control how long old binlog files stay around. The default is 2592000 seconds (30 days) which is often too long.
Post reply on HN