Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1smS3c-005qnb-Ba for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Sep 2024 06:02:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1smS3Z-007wN5-Br for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Sep 2024 06:02:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1smS3Z-007wMG-2O for pgsql-hackers@lists.postgresql.org; Fri, 06 Sep 2024 06:02:53 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1smS3W-000Oyq-TP for pgsql-hackers@postgresql.org; Fri, 06 Sep 2024 06:02:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Transfer-Encoding:Content-Type: Mime-Version:References:In-Reply-To:From:Subject:Cc:To:Message-Id:Date:Sender :Reply-To:Content-ID:Content-Description; bh=kRVmXp65LA+q82aLdBqe18jpf8KocRC6PH5W67oaHI0=; b=jW6TDZaHFP41fWsWq7v/yfaKFr 21hKlRXXUM2+VlQbkNPdqXtBZ9Shl+nqNl87FTcz1tS9o+rF9w+X00QUg8Kg5gteer7VzOd6M3KQ4 49/QHFY7FdTea0iuzTtUrqUKeFfvkam3mLB7+/dbNycYTh8QjX38GvMzS2unO7plK8PKXMOKNswJw rKeFSliSKJEsA+Lb4bVCLkIj+l+VoYEUwL/ZT/TsGBCjpVeXnoL92ycw3g4NZERi8ZkYJhYTNuZc2 hzkRRS8zn+w09teS1cuOOSfNPxAMo3+4qcZkih2B3qEQp3uf1U5CwZTyE/CSk+VtHmAheJztpjdY7 dujOTRFg==; Received: from 185.184.178.217.shared.user.transix.jp ([217.178.184.185] helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1smS3T-000u8W-31; Fri, 06 Sep 2024 06:02:50 +0000 Date: Fri, 06 Sep 2024 15:02:37 +0900 (JST) Message-Id: <20240906.150237.57111972562260411.ishii@postgresql.org> To: dgrowleyml@gmail.com Cc: ashutosh.bapat.oss@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Add memory/disk usage for WindowAgg nodes in EXPLAIN From: Tatsuo Ishii In-Reply-To: References: <20240905.143809.436581948007856565.ishii@postgresql.org> <20240906.132131.1196176059464159407.ishii@postgresql.org> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Thanks for making the adjustments to this. > > I don't think there is any need to call tuplestore_updatemax() from > within writetup_heap(). That means having to update the maximum space > used every time a tuple is written to disk. That's a fairly massive > overhead. > > Instead, it should be fine to modify tuplestore_updatemax() to set a > flag to true if state->status != TSS_INMEM and then record the disk > space used. That flag won't ever be set to false again. > tuplestore_storage_type_name() should just return "Disk" if the new > disk flag is set, even if state->status == TSS_INMEM. Since the > work_mem size won't change between tuplestore_clear() calls, if we've > once spilt to disk, then we shouldn't care about the memory used for > runs that didn't. Those will always have used less memory. > > I did this quickly, but playing around with the attached, I didn't see > any slowdown. Your patch looks good to me and I confirmed that with your patch I didn't see any slowdown either. Thanks! Best reagards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp