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 1sm5CO-0036kH-Jq for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 05:38:29 +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 1sm5CM-003kKL-Li for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 05:38:27 +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 1sm5CM-003kKD-7e for pgsql-hackers@lists.postgresql.org; Thu, 05 Sep 2024 05:38:26 +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 1sm5CJ-000Eaq-Em for pgsql-hackers@postgresql.org; Thu, 05 Sep 2024 05:38:25 +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=U7VJRZUhMCjlMGHtyhzi4+49dIRx4FGc5fm34SerotI=; b=F2e7jI7dzlEMAIfAYpOmV1UnHn SgKfjDJkOUudv/YjgPh+nETiv8LDyTpVj4qSC9ueuM87atZUEVG/kJGXmD1YgNEokp25fSc5de5Nv /ukAKd2ZQkV2166DUz9D6HqM7Us7Uvi4L9U1OhZ6PGS1fSp7ltqsO6x491+T5/Q8dz67lli6QnHuI n/E7ZKwUy9fBc9vLN0nRO1GqixxIwRkJB5FQBrMfkJwFqhdEHiSY0z3DB1Zm00xh/KtZGw1vKVX9b z3ZG1QtH1nEkalZ3Zj8PhlDuLOXwSri2JGcTd0gwT1HNamgXVAToSTQAOjtGW5XvgWaIHG74p7Pym SU+i3NTw==; 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 1sm5CF-000YOJ-LD; Thu, 05 Sep 2024 05:38:23 +0000 Date: Thu, 05 Sep 2024 14:38:09 +0900 (JST) Message-Id: <20240905.143809.436581948007856565.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: <20240709.154409.1091516017393224028.ishii@postgresql.org> <20240710.183610.1211398886785110571.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 Hi, > On Wed, 10 Jul 2024 at 21:36, Tatsuo Ishii wrote: >> v2-0005-Add-memory-disk-usage-for-Window-Aggregate-nodes-.patch: This >> adds memory/disk usage for Window Aggregate nodes in EXPLAIN (ANALYZE) >> command. Note that if David's proposal >> https://www.postgresql.org/message-id/CAHoyFK9n-QCXKTUWT_xxtXninSMEv%2BgbJN66-y6prM3f4WkEHw%40mail.gmail.com >> is committed, this will need to be adjusted. > > Hi, > > I pushed the changes to WindowAgg so as not to call tuplestore_end() > on every partition. Can you rebase this patch over that change? > > It would be good to do this in a way that does not add any new state > to WindowAggState, you can see that I had to shuffle fields around in > that struct because the next_parition field would have caused the > struct to become larger. I've not looked closely, but I expect this > can be done by adding more code to tuplestore_updatemax() to also > track the disk space used if the current storage has gone to disk. I > expect the maxSpace field can be used for both, but we'd need another > bool field to track if the max used was by disk or memory. > > I think the performance of this would also need to be tested as it > means doing an lseek() on every tuplestore_clear() when we've gone to > disk. Probably that will be dominated by all the other overheads of a > tuplestore going to disk (i.e. dumptuples() etc), but it would be good > to check this. I suggest setting work_mem = 64 and making a test case > that only just spills to disk. Maybe do a few thousand partitions > worth of that and see if you can measure any slowdown. Thank you for the suggestion. I will look into this. Best reagards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp