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.96) (envelope-from ) id 1wfclv-005Xsw-03 for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2026 12:13:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wfclt-007RIn-2v for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2026 12:13:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wfclt-007RIe-1C for pgsql-hackers@lists.postgresql.org; Fri, 03 Jul 2026 12:13:29 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wfclq-00000001IyF-1i5O for pgsql-hackers@postgresql.org; Fri, 03 Jul 2026 12:13:28 +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=GqYFdW3GZZaVAHwYiLykqfSBAVwZc43agKO53VWtLKI=; b=xQErsVl7TtQW0rFSMeS4jMH44a st+hBxW5EUXTiws24msaABNbbdZeVmKw75ZT2lH+X2c+TZAXAGuHiMljxrFLYxTnekVVKR/Ttjx54 3CVeDcc4gElXdflK+TyOs4S6KKavs6SmCbYvbBC8OewDUwI76ehyWdyJZaRhT6x3qzej0Gy+flyqb x7R8SinRK33NXrt1s89MvCiUu3XUKh75oNv5afiEpIuIlrTN0Tv8WWZgDFk5Lgbq/OJ05Z9IFZN2X dO4F8hiG+IxZ1RFzLHduYtPH4/LDEclRgpAJNePqOBTSJgb9gQQ1+LMdgUFpditbsUqnQlVH3KsoS 6IpSkcrQ==; Received: from [2409:11:4120:300:59ce:4c3e:181a:f66a] (helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wfclm-009P2z-2e; Fri, 03 Jul 2026 12:13:25 +0000 Date: Fri, 03 Jul 2026 21:13:09 +0900 (JST) Message-Id: <20260703.211309.1130370315247638762.ishii@postgresql.org> To: assam258@gmail.com, jian.universality@gmail.com Cc: pgsql-hackers@postgresql.org, zsolt.parragi@percona.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com Subject: Re: Row pattern recognition From: Tatsuo Ishii In-Reply-To: <20260701.211805.2273383346456030984.ishii@postgresql.org> References: <20260629.183730.1799088184925453299.ishii@postgresql.org> <20260701.211805.2273383346456030984.ishii@postgresql.org> X-Mailer: Mew version 6.8 on Emacs 29.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2409:11:4120:300:59ce:4c3e:181a:f66a (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Henson, Jian, In v50-0006-tidy-plumbing.patch, the planner cost model seems slightly changed. Before the cost was charged according to the number of pattern variables in PATTERN clause. But now it is charged according to the number of pattern variables in DEFINE clause. Maybe I missed the discussion on the changing. Can you please explain the reason of the change? --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -3231,30 +3231,18 @@ cost_windowagg(Path *path, PlannerInfo *root, * so we'll just do this for now. * * Moreover, if row pattern recognition is used, we charge the DEFINE - * expressions once per tuple for each variable that appears in PATTERN. + * expressions once per tuple for each DEFINE variable. */ if (winclause->rpPattern) { - List *pattern_vars; QualCost defcosts; - pattern_vars = collectPatternVariables(winclause->rpPattern); - - foreach_node(String, pv, pattern_vars) + foreach_node(TargetEntry, def, winclause->defineClause) { - char *ptname = strVal(pv); - - foreach_node(TargetEntry, def, winclause->defineClause) - { - if (!strcmp(ptname, def->resname)) - { - cost_qual_eval_node(&defcosts, (Node *) def->expr, root); - startup_cost += defcosts.startup; - total_cost += defcosts.per_tuple * input_tuples; - } - } + cost_qual_eval_node(&defcosts, (Node *) def->expr, root); + startup_cost += defcosts.startup; + total_cost += defcosts.per_tuple * input_tuples; } Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp