今天发现一些SQL报错“ERROR 1038 (HY001): Out of sort memory, consider increasing server sort buffer size”,之前版本没有问题,google了一下发现了这个BUG https://bugs.mysql.com/bug.php?id=103225,官方的回复说这不是一个BUG,是一个新特性:
A potentially relevant change is that somewhere between those versions, we started sorting small blobs, such as TEXT, as addon fields instead of always doing sort-by-rowid. This is the reason why there’s now more pressure on the sort buffer (but for most cases, sorts should still be faster).
在8.0的某个版本,MySQL将text字段也保存到sort buffer中,导致8.0版本需要配置比之前版本更大的sort buffer,至于需要配置多大,官方建议至少能够容纳15条记录。
At minimum the sort_buffer_size value must be large enough to accommodate fifteen tuples in the sort buffer
如果不想增加sort_buffer_size,也可以将text字段改为longtext类型,longtext类型与之前版本一样不会保存到sort buffer。