그배트맨 토토module provides a convenient way to load relation data into either the operating system buffer cache or the포스트그레SQL버퍼 캐시. 사전 예열은 다음을 사용하여 수동으로 수행할 수 있습니다.배트맨 토토기능 또는 다음을 포함하여 자동으로 수행될 수 있습니다.배트맨 토토inshared_preload_libraries. In the latter case, the system will run a background worker which periodically records the contents of shared buffers in a file calledautoprewarm.blocksand will, using 2 background workers, reload those same blocks after a restart.
배트맨 토토(regclass, mode text default 'buffer', fork text default 'main',
first_block int8 기본값은 null,
last_block int8 기본값 null) RETURNS int8
The first argument is the relation to be prewarmed. 두 번째 주장은 아래에서 자세히 설명하는 것처럼 사용할 예열 방법입니다. 세 번째는 일반적으로 미리 데워질 관계 포크입니다.메인. 네 번째 인수는 사전 준비할 첫 번째 블록 번호입니다(NULL0의 동의어로 허용됩니다). 다섯 번째 인수는 사전 준비할 마지막 블록 번호입니다(NULL관계의 마지막 블록을 통해 prewarm을 의미합니다). 반환 값은 미리 예열된 블록 수입니다.
세 가지 사전 예열 방법이 있습니다.프리페치issues asynchronous prefetch requests to the operating system, if this is supported, or throws an error otherwise.읽기요청된 블록 범위를 읽습니다. 달리프리패치, this is synchronous and supported on all platforms and builds, but may be slower.버퍼요청된 블록 범위를 데이터베이스 버퍼 캐시로 읽어옵니다.
이 방법 중 하나를 사용하면 캐시할 수 있는 것보다 더 많은 블록을 예열하려고 시도한다는 점에 유의하세요. — 사용 시 OS에 의해프리페치또는읽기또는 작성자:포스트그레SQL사용 시버퍼— will likely result in lower-numbered blocks being evicted as higher numbered blocks are read in. Prewarmed data also enjoys no special protection from cache evictions, so it is possible that other system activity may evict the newly prewarmed blocks shortly after they are read; 반대로 사전 준비로 인해 캐시에서 다른 데이터가 제거될 수도 있습니다. 이러한 이유로 사전 준비는 일반적으로 캐시가 거의 비어 있는 시작 시 가장 유용합니다.
autoprewarm_start_worker() 반환 무효
Launch the main autoprewarm worker. This will normally happen automatically, but is useful if automatic prewarm was not configured at server startup time and you wish to start up the worker at a later time.
autoprewarm_dump_now() 반환 int8
업데이트autoprewarm.blocks즉시. This may be useful if the autoprewarm worker is not running but you anticipate running it after the next restart. The return value is the number of records written toautoprewarm.blocks.
이 매개변수는 다음에서 설정되어야 합니다.postgresql.conf. 일반적인 사용법은 다음과 같습니다:
# postgresql.conf shared_preload_libraries = '배트맨 토토' 배트맨 토토.autoprewarm = true 배트맨 토토.autoprewarm_interval = 300초
Robert Haas<rhaas@postgresql.org