PostgreSQL memory Parameters

Source: Internet
Author: User
The configuration file of PostgreSQL is PostgreSQL in the database directory. CONF file. Versions later than 8.0 support parameters such as K, M, and G. You only need to modify the corresponding parameters and restart the PG service.

Shared_buffers:This is the most important parameter. PostgreSQL uses shared_buffers to deal with the kernel and disk, so it should be as large as possible to make more data cached in shared_buffers. It is generally reasonable to set 10% of the actual Ram, such as 50000 (400 m)

Work_mem:Before pgsql 8.0, it is called sort_mem. When executing the sorting operation, PostgreSQL determines whether to split a large result set into several small temporary files with few size queries based on the size of work_mem. Obviously, the splitting result reduces the sorting speed. Therefore, adding work_mem helps increase the sorting speed. Usually set to 2%-4% of the actual Ram, depending on the size of the result set to be sorted, such as 81920 (80 m)

Effective_cache_size:It is the maximum cache that PostgreSQL can use. This number should be large enough for an independent pgsql server. For example, the 4 GB memory can be set to 3.5 GB (437500)

Maintence_work_mem:The memory defined here is only used in create index, vacuum, and so on, so the usage frequency is not high, but these commands often consume a large amount of resources, therefore, the execution of these commands should be completed as soon as possible: large memory size for maintence_work_mem, such as 512 M (524288)

Max_connections:Generally, max_connections aims to prevent max_connections * work_mem from exceeding the actual memory size. For example, if you set work_mem to 2% of the actual memory size, in extreme cases, if 50 queries have sorting requirements, and 2% of the memory is used, this will lead to the generation of swap, and the system performance will be greatly reduced. Of course, if there is 4 GB memory, the probability of 50 such large queries at the same time should be very small. However, you need to understand the relationship between max_connections and work_mem.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.