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 1sbzb7-0032Ru-7N for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Aug 2024 09:38:17 +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 1sbzb5-00D21f-91 for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Aug 2024 09:38:15 +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.94.2) (envelope-from ) id 1sbzb4-00D20v-VM for pgsql-hackers@lists.postgresql.org; Thu, 08 Aug 2024 09:38:14 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbzay-003gdU-6U for pgsql-hackers@postgresql.org; Thu, 08 Aug 2024 09:38:13 +0000 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2f149845d81so8166891fa.0 for ; Thu, 08 Aug 2024 02:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723109886; x=1723714686; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9S/99hQXOLMzWMuBxf2AB8eyMDOJ+rFhrO42kAxdXkc=; b=W1OQFVf6FmBWdlgDrWm0Z0Trk3B8kwpP6lZZWMigSL68JrnUXhzwfp0ptyz3854zk1 hndpsLcJd3Kj196nRbwtBqBuJiHfeKkGNYK9gDfirZ9VVNk2t+2SkVDUNEt7o7B27mt8 qmaoDAO89WVHiSWJ4v24Fo9JeIBpNkyj9dCbT7iLSAB7c9TKtXTX+teuqA7QMpbl51uk IgNAcbePlIn/EPrxvb86qvbIleq4AkzUGGwNOl9PZYdHxlhI+AqR2nlkkLc8yKwBq5Zk i3wsPAX7UHi0B6Gkm+hvEWcqswVfIBljgK8rXC1dDRYU7uyyN0MQ3Kof1lbhTDfRV5ER s7Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723109886; x=1723714686; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9S/99hQXOLMzWMuBxf2AB8eyMDOJ+rFhrO42kAxdXkc=; b=lEAhBGYBp2e0hvLAgXqOCkoGKQSZa6/rnIqTyZfDKtjc+GqrM8js9K+RsQlBWFoFbR zVjxixnvmokzOXWvbXwyKPW+cOy/YSuwoh9We/Ms4Km2MbvcJ2fDX6Ajcctl/xA2Lled J7tquY5o6gqKrLhrd40NQfBD/jbQLG1cK/U7l6nLnVC05KiXMKaL8WJ7qEJqHRW3MBDi hr8wLeevZ/gZ1p9a8Ve+ooXSE1W++3XLjcAkUmsszQFdVIrzWpF3uEQD9YwmiEnSF0q7 zCLCqVAvmnDRSZ1Kh/mMJ/Ca6OKvs3kyEr6jeBVHTvs7YRyWASYMG6Uoq8r7vk5Udslr HeSA== X-Forwarded-Encrypted: i=1; AJvYcCVgZ/Tqgag/Z+Xc6JEaUtV96g5ZqRZ6nzuG0MgjFx8tKa0RYcLmX3oXAjuYXMDNj1Y5R8D14k0IJqLyGZuJpFfB7ydLCYAzlbmkalP0 X-Gm-Message-State: AOJu0YyPLjqS40MrrvKwgg/Ph9VpUCGejwsHK0No0vMeky54zPuc2bYQ vMynDgIErFsOUBAdnuhl36ltuukr7jshkQyYWWKcFxxZxmVf9xIyBhfusVfkq5iVfml7FTMKow4 W6SJu7AulbjKrBjHiFl05LWuEDrU= X-Google-Smtp-Source: AGHT+IEGWKqR8lEHaeR3/IgG64kxqeha0cSqEna9OTRTZncUVfPUq+M41MjYxwiZUJ2WkSADQl7FkDNW5oOHARzBAaA= X-Received: by 2002:a2e:1302:0:b0:2ef:1f68:eae1 with SMTP id 38308e7fff4ca-2f19de30b78mr6871101fa.17.1723109886013; Thu, 08 Aug 2024 02:38:06 -0700 (PDT) MIME-Version: 1.0 References: <20230828115252.c1b018605b9a0756a30c3382@sraoss.co.jp> <20230828160530.adde1e20f257d7d345989163@sraoss.co.jp> <20230902.204634.955758704959569058.t-ishii@sranhm.sra.co.jp> <20240123162327.c2803162619dd7634cca0b6c@sraoss.co.jp> <20240304115846.2275fb44fd904e8789d43590@sraoss.co.jp> <20240329234700.73ff2e28c9248d29f8fa6a66@sraoss.co.jp> <20240331225931.712683cecb26862b73b2b822@sraoss.co.jp> <20240702170311.1ddb417759a48ff12c555b92@sranhm.sraoss.co.jp.sranhm> <20240711132357.fe3f78c184cfa99159208178@sranhm.sraoss.co.jp> In-Reply-To: <20240711132357.fe3f78c184cfa99159208178@sranhm.sraoss.co.jp> From: Kirill Reshke Date: Thu, 8 Aug 2024 14:37:54 +0500 Message-ID: Subject: Re: Incremental View Maintenance, take 2 To: Yugo NAGATA Cc: Peter Smith , jian he , Tatsuo Ishii , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I am really sorry for splitting my review comments into multiple emails. I'll try to do a better review in a future, all-in-one. On Thu, 11 Jul 2024 at 09:24, Yugo NAGATA wrote: > > On Tue, 2 Jul 2024 17:03:11 +0900 > Yugo NAGATA wrote: > > > On Sun, 31 Mar 2024 22:59:31 +0900 > > Yugo NAGATA wrote: > > > > > > > > Also, I added a comment on RelationIsIVM() macro persuggestion from jian he. > > > > In addition, I fixed a failure reported from cfbot on FreeBSD build caused by; > > > > > > > > WARNING: outfuncs/readfuncs failed to produce an equal rewritten parse tree > > > > > > > > This warning was raised since I missed to modify outfuncs.c for a new field. > > > > > > I found cfbot on FreeBSD still reported a failure due to > > > ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS because the regression test used > > > wrong role names. Attached is a fixed version, v32. > > > > Attached is a rebased version, v33. > > I updated the patch to bump up the version numbers in psql and pg_dump codes > from 17 to 18. > > Regards, > Yugo Nagata > > > > > Regards, > > Yugo Nagata > > > > > > -- > > Yugo NAGATA > > > -- > Yugo NAGATA 1) Provided patches do not set process title correctly: ``` reshke 2602433 18.7 0.1 203012 39760 ? Rs 20:41 1:58 postgres: reshke ivm [local] CREATE MATERIALIZED VIEW ``` 2) We allow to REFRESH IMMV. Why? IMMV should be always up to date. Well, I can see that this utility command may be useful in case of corruption of some base relation/view itself, so there will be a need to rebuild the whole from scratch. But we already have VACUUM FULL for this, aren't we? 3) Triggers created for IMMV are not listed via \dS [tablename] 4) apply_old_delta_with_count executes non-trivial SQL statements for IMMV. It would be really helpful to see this in EXPLAIN ANALYZE. 5) > + "DELETE FROM %s WHERE ctid IN (" > + "SELECT tid FROM (SELECT pg_catalog.row_number() over (partition by %s) AS \"__ivm_row_number__\"," > + "mv.ctid AS tid," > + "diff.\"__ivm_count__\"" > + "FROM %s AS mv, %s AS diff " > + "WHERE %s) v " > + "WHERE v.\"__ivm_row_number__\" OPERATOR(pg_catalog.<=) v.\"__ivm_count__\")", > + matviewname, > + keysbuf.data, > + matviewname, deltaname_old, > + match_cond); `SELECT pg_catalog.row_number()` is too generic to my taste. Maybe pg_catalog.immv_row_number() / pg_catalog.get_immv_row_number() ? 6) > +static void > +apply_new_delta(const char *matviewname, const char *deltaname_new, > + StringInfo target_list) > +{ > + StringInfoData querybuf; >+ > + /* Search for matching tuples from the view and update or delete if found. */ Is this comment correct? we only insert tuples here? 7) During patch development, one should pick OIDs from range 8000-9999 > +# IVM > +{ oid => '786', descr => 'ivm trigger (before)', > + proname => 'IVM_immediate_before', provolatile => 'v', prorettype => 'trigger', > + proargtypes => '', prosrc => 'IVM_immediate_before' }, > +{ oid => '787', descr => 'ivm trigger (after)', > + proname => 'IVM_immediate_maintenance', provolatile => 'v', prorettype => 'trigger', > + proargtypes => '', prosrc => 'IVM_immediate_maintenance' }, > +{ oid => '788', descr => 'ivm filetring ', > + proname => 'ivm_visible_in_prestate', provolatile => 's', prorettype => 'bool', > + proargtypes => 'oid tid oid', prosrc => 'ivm_visible_in_prestate' }, > ] -- Best regards, Kirill Reshke