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 1sXclh-005DN2-JR for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jul 2024 08:27:09 +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 1sXcle-003UF2-45 for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jul 2024 08:27:06 +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 1sXcld-003UEu-Q3 for pgsql-hackers@lists.postgresql.org; Sat, 27 Jul 2024 08:27:05 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sXclX-001gj1-Ev for pgsql-hackers@postgresql.org; Sat, 27 Jul 2024 08:27:04 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2f035ae1083so25052391fa.3 for ; Sat, 27 Jul 2024 01:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722068818; x=1722673618; 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=WfrabAi5IxFgtB+6PXvrqkAnnutnN8ibYMowfl6KRs0=; b=IQpdRjG5jL+V4jjfGkywoOlsIEPhRHPDPsBTRT687aymgFmb/V3NsTxSGphHFtL+KS fwJEZkGL5724aAPZWUCEO8k+CLZ8wagtlZCJN025qouEX38Ae/t7sbufm5SpJ6dLxFYR dd8pLoUPzz+DIRahyHFj2KH4imSag1snGINNqOv0spvQEkikSE8WZHMLOccb1BY/ZbW1 CmpjVVlf2TQYtX5QktcRxIrWhV/lz4VXGix4d18lLxfus8aofNbhLzOsMkjci9ZEyzcK 6GhosqlFNaai8M2kTPuU3+L6DtZEWxzpa278uon8+eed88zsSEFWRqQEgb1b9stIABDA 3D4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722068818; x=1722673618; 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=WfrabAi5IxFgtB+6PXvrqkAnnutnN8ibYMowfl6KRs0=; b=c/YF6nwNFv+f3biuZlX8uv+YjYGUA9N00wJQQn/h4vJpsy5qAZDCgWA0BuQTWumg7Z KX2cqGVUIQHX+OuFNwETMLbLU4CeF4P/U24RGVQUsn42kbAflFgrN9KAH0fIekqnr+P4 u4eD5LN9M/W698U1hGFNlhmVdTahQZATPMLZJjnF6nlEY978XnBVkx/MC/9f0Zs80FF7 6lI3YKyltrirEVgup9oDKrvKVRay+/He+2YOjTANGJZ2gjFQXpXFGWClAp7aBY+t8CbE yuRZoxGkvc6d6iw2lsdLD18hOtHSG3SD1xFFwuH6ExYDlM7OmPSfV/5hlcLBdmO9Hpph hNyg== X-Forwarded-Encrypted: i=1; AJvYcCXwBl8hHMGUVUeCLsyhIshONobLSWm/+6Mlfo+ijZZ5X7IwUQxz4ppH3oDjEIXS+LILxooeKDp0fxra2KAPakG8EF5ne7RFcVkR97Ww X-Gm-Message-State: AOJu0YyTz4LQx/+f5cxpuPn3sRwHjl4WYT4prJ5mObPyRTS2ztHgTEU6 eQVaj0TKtV0k36XjfjpynLgG+K8f8f8pfB4LNbkm3NkYOjMXTP8jLCH9SrAGgI5w4HHSWwJL7JE DN6It0Y1bJKtPL2XXrHQrKuyYLT0= X-Google-Smtp-Source: AGHT+IHsd2nO9mZwdaTeVCOIu6kZV9GkolK1uncC7gyyzFTOzDYJ0ncBIu/6/49zXLnwjB+eUJuDjMa22Jm9+wDidX8= X-Received: by 2002:a2e:8710:0:b0:2ec:42db:96a2 with SMTP id 38308e7fff4ca-2f12ee28b00mr11590371fa.29.1722068817496; Sat, 27 Jul 2024 01:26:57 -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: Sat, 27 Jul 2024 13:26:46 +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 Hi! Cloudberry DB (Greenplum fork) uses IMMV feature for AQUMV (auto query use matview) feature, so i got interested in how it is implemented. On Thu, 11 Jul 2024 at 09:24, Yugo NAGATA wrote: > > I updated the patch to bump up the version numbers in psql and pg_dump codes > from 17 to 18. Few suggestions: 1) `Add-relisivm-column-to-pg_class-system-catalog` commit message should be fixed, there is "isimmv" in the last line. 2) I dont get why `Add-Incremental-View-Maintenance-support.patch` goes after 0005 & 0004. Shoulndt we first implement feature server side, only when client (psql & pg_dump) side? 3) Can we provide regression tests for each function separately? Test for main feature in main patch, test for DISTINCT support in v34-0007-Add-DISTINCT-support-for-IVM.patch etc? This way the patchset will be easier to review, and can be committed separelety. 4) v34-0006-Add-Incremental-View-Maintenance-support.patch no longer applies due to 4b74ebf726d444ba820830cad986a1f92f724649. After resolving issues manually, it does not compile, because 4b74ebf726d444ba820830cad986a1f92f724649 also removes save_userid/save_sec_context fields from ExecCreateTableAs. > if (RelationIsIVM(matviewRel) && stmt->skipData) Now this function accepts skipData param. 5) For DISTINCT support patch uses hidden __ivm* columns. Is this design discussed anywhere? I wonder if this is a necessity (only solution) or if there are alternatives. 6) What are the caveats of supporting some simple cases for aggregation funcs like in example? ``` regress=# CREATE INCREMENTAL MATERIALIZED VIEW mv_ivm_2 AS SELECT sum(j) + sum(i) from mv_base_a; ERROR: expression containing an aggregate in it is not supported on incrementally maintainable materialized view ``` I can see some difficulties with division CREATE IMMV .... AS SELECT 1/sum(i) from mv_base_a; (sum(i) == 0 case), but adding & multiplication should be ok, aren't they? Overall, patchset looks mature, however it is far from being committable due to lack of testing/feedback/discussion. There is only one way to fix this... Test and discuss it! [1] https://github.com/cloudberrydb/cloudberrydb