类型: integer
默认: 4096 (4MB)
最低限度: 64 (64kB)
最大: 2147483647 (2147483647kB)
单元: KB
上下文: user
重新开始: false

设置在写入临时磁盘文件之前查询操作(例如排序或哈希表)可使用的最大内存容量。 如果指定值时没有单位,则以千字节为单位。默认值是4兆字节 (4MB)。 注意对于一个复杂查询, 可能会并行运行好几个排序或者哈希操作;每个操作都会被允许使用这个参数指定的内存量,然后才会开始写数据到临时文件。同样,几个正在运行的会话可能并发进行这样的操作。因此被使用的总内存可能是work_mem值的好几倍,在选择这个值时一定要记住这一点。ORDER BYDISTINCT和归并连接都要用到排序操作。哈希连接、基于哈希的聚集以及基于哈希的IN子查询处理中都要用到哈希表。

建议 [EN]

Sets the limit for the amount of non-shared RAM available for each query operation, including sorts and hashes. This limit acts as a primitive resource control, preventing the server from going into swap due to overallocation. Note that this is non-shared RAM per operation, which means large complex queries can use multple times this amount. Also, work_mem is allocated by powers of two, so round to the nearest binary step. The second formula is for reporting and DW servers which run a lot of complex queries.

条评论