|
杨奇龙 发表于 2013-9-14 00:30 ![]()
抱歉,表述单位有误,你是正确的。
本身内存比较难以衡量 一个结果集占用了多少内存。关于第一点 你可 ...
关于第一点 我还是认为只会分配100个字符给字段a, 如果这时一个非常复杂的查询 比如产生filesort , temp table 等 这个是需要使用到200的。
高性能MySQL中第三章看到这么一段话:
Storing the value 'hello' requires the same amount of space in a VARCHAR(5) and a
VARCHAR(200) column. Is there any advantage to using the shorter column?
As it turns out, there is a big advantage. The larger column can use much more memory, because MySQL often allocates fixed-size chunks of memory to hold values internally. This is especially bad for sorting or operations that use in-memory temporary tables. The same thing happens with filesorts that use on-disk temporary tables.
The best strategy is to allocate only as much space as you really need.
不知到你疑惑的是不是 because MySQL often allocates fixed-size chunks of memory to hold values internally,个人感觉这个应该不是只为每个可变字段分配最大内存,这个非常没有必要,想想如果是我们来设计数据库? 我想也不会这样来设计
|
|