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 1l2KCt-0006X1-F7 for pgsql-general@arkaria.postgresql.org; Wed, 20 Jan 2021 20:35:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2KCs-00008K-Cp for pgsql-general@arkaria.postgresql.org; Wed, 20 Jan 2021 20:35:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2KCs-00008D-5G for pgsql-general@lists.postgresql.org; Wed, 20 Jan 2021 20:35:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2KCq-0000PD-66 for pgsql-general@lists.postgresql.org; Wed, 20 Jan 2021 20:35:57 +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 10KKZtnj785365; Wed, 20 Jan 2021 15:35:55 -0500 From: Tom Lane To: Michael Lewis cc: PostgreSQL General Subject: Re: work_mem, temp_buffers, and temp_file_limit In-reply-to: References: Comments: In-reply-to Michael Lewis message dated "Wed, 20 Jan 2021 13:30:49 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <785363.1611174954.1@sss.pgh.pa.us> Date: Wed, 20 Jan 2021 15:35:55 -0500 Message-ID: <785364.1611174955@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Lewis writes: > I've read the documentation but am unclear on what memory is used when > temp_buffers are exceeded by temp tables that are created. The data gets flushed out to disk storage, or at least kernel disk buffers (I don't think we'll try to fsync it). > Does that also go towards temp_file_limit? No, a "temp file" is distinct from a temporary relation. Temp files are used for anonymous transient stuff like a hash join's hash table. > When are temp files (temp_file_limit) cleared out? At the end of the query that used them. regards, tom lane