Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcZNS-0000RQ-GC for pgsql-admin@arkaria.postgresql.org; Tue, 10 Nov 2020 19:32:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kcZNP-0005Bp-9X for pgsql-admin@arkaria.postgresql.org; Tue, 10 Nov 2020 19:32:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcZNP-0005Bi-29 for pgsql-admin@lists.postgresql.org; Tue, 10 Nov 2020 19:32:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcZNM-0000qX-TI for pgsql-admin@postgresql.org; Tue, 10 Nov 2020 19:32:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0AAJWHEn2201082; Tue, 10 Nov 2020 14:32:17 -0500 From: Tom Lane To: "David G. Johnston" cc: Wells Oliver , pgsql-admin Subject: Re: temp_buffers and work_mem and big temp tables In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Tue, 10 Nov 2020 12:04:36 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2201080.1605036737.1@sss.pgh.pa.us> Date: Tue, 10 Nov 2020 14:32:17 -0500 Message-ID: <2201081.1605036737@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > On Tuesday, November 10, 2020, Wells Oliver wrote: >> Hey all: I was wondering if someone might spell out which setting has more >> impact on temporary tables being stored in memory versus disk? I have read >> the docs but I thought I'd reach out and ask the community: I keep >> increasing both in some scripts where Large Temp Tables are created, but >> I'm wondering if it's more efficient just to use one or the other. > IIUC work_mem has nothing to do with temporary tables. All tables have a > disk component and read/writes are done via buffers. The temp_buffers setting controls how much temporary-table data can be kept in a session's memory. If you get to more than that, it spills out to disk (or at least to the kernel's disk buffers). regards, tom lane