Design of a memory-only PostgreSQL buffer for a database
Source: Internet
Author: User
According to the development of Java Mall, the development of JSP Mall and the developer of Java Mall products, PostgreSQL needs to do its own buffering technology in development, because there are many cases where I/O buffering is used for various reasons. This causes a problem: the data in the database is often stored two times in memory, once in the PostgreSQL buffer, and on the page cache at the other time. PostgreSQL greatly increases memory usage to a certain extent and is harmful to a complete system. A large amount of memory wasting behavior should be effectively eliminated. Consider an example where there is a dirty data (dirty buffer) on the PostgreSQL cache, which is newer than the kernel-owned data on the page buffer memory. When PostgreSQL refreshes this dirty data, this important process of page buffer memory rewriting will not occur, so the data will not be synchronized. In this case, PostgreSQL will be able to tell the kernel to remove the corresponding page on the page buffer memory, but the reality is that there is no good API to do it now. According to Andrew (Andres), it is possible to invoke the Fadv_dontneed parameter of the Fadvise () function, which, in fact, will cause the specified page to be read out, and almost no one can understand this behavior well, but they all agree that it should not work this way. Nor can they use the madvise () function before mapping to file processing, so that a large number of working processes can become very slow. This looks good, but it may also move a few pages in the opposite direction, and PostgreSQL may want to remove a clean page from its own buffer, but leaves a copy in the page buffer. The possible scenario is a special write operation that actually does not cause I/O, or a system call that transforms a physical page into a page buffer. These superficial discussions are quite numerous, but no part of the discussion is able to give a definitive conclusion.
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.