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 1qaINh-008mrX-GF for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Aug 2023 16:12:53 +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 1qaINg-001Aqs-3u for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Aug 2023 16:12:51 +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 1qaINf-001Aqh-QE for pgsql-hackers@lists.postgresql.org; Sun, 27 Aug 2023 16:12:51 +0000 Received: from ml.sraoss.co.jp ([66.11.59.17]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qaINX-001MYG-SV for pgsql-hackers@postgresql.org; Sun, 27 Aug 2023 16:12:50 +0000 Received: from sranhm.sraoss.co.jp (unknown [192.168.174.164]) by osspc26.sraoss.co.jp (Postfix) with ESMTP id 64B9F2F00100; Mon, 28 Aug 2023 01:12:41 +0900 (JST) Received: from yugon-CFSV7-1 (unknown [192.168.176.1]) by sranhm.sraoss.co.jp (Postfix) with SMTP id 3FECC34171E; Mon, 28 Aug 2023 01:12:41 +0900 (JST) Date: Mon, 28 Aug 2023 01:12:41 +0900 From: Yugo NAGATA To: jian he Cc: pgsql-hackers@postgresql.org Subject: Re: Incremental View Maintenance, take 2 Message-Id: <20230828011241.2d7ee9f96ac9a386e1eb0423@sraoss.co.jp> In-Reply-To: References: <20230601235909.0e1572c27e59112f9d0cbe86@sraoss.co.jp> <20230601034703.9e4f81f5d92ae6e3949b84d2@sraoss.co.jp> <20230628170604.505955118ac2f91abd554f13@sraoss.co.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) 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 On Sun, 2 Jul 2023 08:25:12 +0800 jian he wrote: > This is probably not trivial. > In function apply_new_delta_with_count. > > appendStringInfo(&querybuf, > "WITH updt AS (" /* update a tuple if this exists in the view */ > "UPDATE %s AS mv SET %s = mv.%s OPERATOR(pg_catalog.+) diff.%s " > "%s " /* SET clauses for aggregates */ > "FROM %s AS diff " > "WHERE %s " /* tuple matching condition */ > "RETURNING %s" /* returning keys of updated tuples */ > ") INSERT INTO %s (%s)" /* insert a new tuple if this doesn't existw */ > "SELECT %s FROM %s AS diff " > "WHERE NOT EXISTS (SELECT 1 FROM updt AS mv WHERE %s);", > > --------------------- > ") INSERT INTO %s (%s)" /* insert a new tuple if this doesn't existw */ > "SELECT %s FROM %s AS diff " > > the INSERT INTO line, should have one white space in the end? > also "existw" should be "exists" Yes, we should need a space although it works. I'll fix as well as the typo. Thank you. Regards, Yugo Nagata -- Yugo NAGATA