在改变
max_allowed_packet之前,首先让我们来定义它.
MysqL network communication code was
written under the assumption that
queries are always reasonably short,
and therefore can be sent to and
processed by the server in one chunk,
which is called a packet in MysqL
terminology. The server allocates the
memory for a temporary buffer to store
the packet,and it requests enough to
fit it entirely. This architecture
requires a precaution to avoid having
the server run out of memory—a cap
on the size of the packet,which this
option accomplishes.
The code of interest in relation to
this option is found in
sql/net_serv.cc. Take a look at my_net_read(),then follow the call to my_real_read() and pay
particular attention to
net_realloc().
This variable also limits the length
of a result of many string functons.
See sql/field.cc and
sql/intem_strfunc.cc for details.
根据本书的摘录和max_allowed_packet上的MysqL文档,对于max_allowed_packet而言,基本上没有什么可以超越1G.但是,还有一个方面需要探讨BLOB和文本数据调优.
关于InnoDB和BLOB,Another question in Server Fault做了以下断言:innodb_log_file_size和innodb_log_buffer_size组合必须大于你的最大blob对象的十倍,如果你有很多大的对象.如果你不这样做(并且你不应该[1,2]),那么真的没有必要用它来打扰.查看MysqL性能博客,获取有关如何计算的详细报告.
还有另一个需要考虑的方面:选项net_buffer_length(默认为16K)用作MysqL数据包的初始化大小.数据包可以动态扩展到max_allowed_packet.它不可避免地缩回到net_buffer_length指定的大小. net_buffer_length的最大值为1M.您可能希望将此值设置为1M.如果您正在驾驶1G,可能没多大帮助,但也不会有任何伤害.
如果你真的想要一个大于1G的MysqL数据包,我引用的那本书摘录告诉你使用什么源代码来定义MysqL数据包内部.您可以自由尝试提高限额.但是,如果代码假定1G除了设置显式数字之外,源代码可能具有自己的内部限制.
我希望这个信息有帮助!