본문으로 건너뛰기

temp_buffers

버전기본값context타입
14eight megabytes ( 8MB )userinteger
15eight megabytes ( 8MB )userinteger
16eight megabytes ( 8MB )userinteger
17eight megabytes ( 8MB )userinteger
18eight megabytes ( 8MB )userinteger
19eight megabytes ( 8MB )userinteger

각 데이터베이스 세션이 temporary table 접근에 쓰는 세션 로컬 buffer의 최대 메모리 양을 정한다. 단위 없이 값을 주면 블록 수(BLCKSZ, 보통 8kB)로 해석하며 기본값은 8MB다.

이 buffer는 shared buffers와 별개로 세션마다 로컬로 할당되며 temporary table 접근에만 쓰인다. 세션은 필요한 만큼 한도까지 temp buffer를 할당해 나간다. 그래서 실제로 temporary table을 쓰지 않는 세션에서 값이 커도 비용은 미미하다. 한도 증가분당 buffer descriptor 약 64바이트가 전부고, buffer가 실제로 사용될 때에야 블록당 8192바이트(BLCKSZ)가 추가로 소비된다.

한 가지 특이한 제약이 있다. 세션 안에서 값을 바꿀 수는 있지만 그 세션이 temporary table을 처음 사용하기 전까지만 유효하다. 이미 temporary table을 쓴 뒤에는 값을 바꿔도 그 세션에는 효과가 없다.

운영 노트: temporary table을 크게 쓰는 배치 세션이라면 작업 시작 직후, temporary table을 만들기 전에 SET temp_buffers를 실행해야 한다. 한도가 부족하면 temporary table I/O가 디스크로 흘러 배치가 느려진다.

출처: PostgreSQL 18 문서