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 1niN51-0001Gd-MA for pgsql-general@arkaria.postgresql.org; Sat, 23 Apr 2022 21:14:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1niN50-0004sK-HB for pgsql-general@arkaria.postgresql.org; Sat, 23 Apr 2022 21:14:10 +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 1niN4z-0004pp-Ti for pgsql-general@lists.postgresql.org; Sat, 23 Apr 2022 21:14:09 +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 1niN4u-0003nS-Sl for pgsql-general@lists.postgresql.org; Sat, 23 Apr 2022 21:14:08 +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 23NLDfsO3989727; Sat, 23 Apr 2022 17:13:41 -0400 From: Tom Lane To: "David G. Johnston" cc: Peter , "pgsql-generallists.postgresql.org" Subject: Re: SELECT creates millions of temp files in a single directory In-reply-to: References: <3987446.1650747468@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Sat, 23 Apr 2022 14:03:57 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3989725.1650748421.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 23 Apr 2022 17:13:41 -0400 Message-ID: <3989726.1650748421@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > I'll add that given the nature of the problem that changing temp_file_li= mit > away from its default of unlimited may be useful. > https://www.postgresql.org/docs/current/runtime-config-resource.html#RUN= TIME-CONFIG-RESOURCE-DISK Maybe ... that limits the total space involved, not the number of files it's separated into, so I'm not sure how much it can help. It might be worth playing around to see how varying values of work_mem affect this behavior, too. That should change the planner's initial estimate of the number of hash batches needed, which likely plays into this somehow. regards, tom lane