Cache Management Functions
Cache management functions are available for clusters of version 9.1.1.100 and later. The functions release caches from shared buffers, accelerating query and optimizing database performance.
Only the system administrator can execute this function.
The three types of interfaces are provided for releasing caches.
- To release a specified buffer, use pg_buffercache_evict(bufferid integer).
- To release all buffers of a specified table, use pg_buffercache_evict(nsp_name name, rel_name name, partition_name name, temp_nsp_name name) and pgxc_buffercache_evict(nsp_name name, rel_name name, partition_name name, temp_nsp_name name).
- To release all buffers, use pg_buffercache_evict() and pgxc_buffercache_evict().
The pinned buffers are not released by cache management functions.
pg_buffercache_evict(bufferid integer)
Description: Releases the buffer with the specified ID.
Return type: bool
Return value description: Whether the buffer is released and successfully written to a disk.
Example:
1 2 3 4 5 |
SELECT pg_catalog.pg_buffercache_evict(1); pg_buffercache_evict ---------------------- t (1 row) |
pg_buffercache_evict(nsp_name name, rel_name name, partition_name name, temp_nsp_name name)
Description: Releases all unpinned buffers of a specified table on the current instance.
Parameter description: Different parameter values need to be specified based on the table type. For details, see Table 2.
Return type: integer
Return value description: Number of buffers that are successfully released.
Example:
1 2 3 4 5 |
SELECT pg_catalog.pg_buffercache_evict('public', 't1', NULL, NULL); pg_buffercache_evict ---------------------- 4 (1 row) |
pgxc_buffercache_evict(nsp_name name, rel_name name, partition_name name, temp_nsp_name name)
Description: Releases all unpinned buffers of a specified table on all instances.
Parameter description: Different parameter values need to be specified based on the table type. For details, see Table 2.
Return type: integer
Return value description: Number of buffers that are successfully released.
Example:
1 2 3 4 5 |
SELECT pg_catalog.pgxc_buffercache_evict('public', 't1', NULL, NULL); pgxc_buffercache_evict ------------------------ 10 (1 row) |
pg_buffercache_evict()
Description: Releases all unpinned buffers on the current instance.
Return type: integer
Return value description: Number of buffers that are successfully released.
Example:
1 2 3 4 5 |
SELECT pg_catalog.pg_buffercache_evict(); pg_buffercache_evict ---------------------- 2654 (1 row) |
pgxc_buffercache_evict()
Description: Releases all unpinned buffers on all instance.
Return type: integer
Return value description: Number of buffers that are successfully released.
Example:
1 2 3 4 5 |
SELECT pg_catalog.pgxc_buffercache_evict(); pgxc_buffercache_evict ------------------------ 10881 (1 row) |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot