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 1sgIwz-000VB4-Hx for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 07:06:41 +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 1sgIwx-00AcVZ-I3 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 07:06:40 +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 1sgIwx-00AcPO-7t for pgsql-hackers@lists.postgresql.org; Tue, 20 Aug 2024 07:06:39 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sgIwu-000ZQs-DV for pgsql-hackers@postgresql.org; Tue, 20 Aug 2024 07:06:39 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ef32fea28dso58919091fa.2 for ; Tue, 20 Aug 2024 00:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724137596; x=1724742396; 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=uBFprpBCFzW7j0ztlYGU3Bm+9Kdh0TsHk9wrCucGg0A=; b=lK6EZu0hJdu2iC9w7qQc0Ek6jOFKfjQA8lP6sr4U5rqDOPuLJiI11HkJ8AtgVNIl9y 5KZOsUVw9N8Ji7lm339zdMvb1KmPuD2nYZc2hbpIA9cTRydrdQxLANDqDVLXlQIIKFBv 3PRt666qCjd6rxnB9rFpLDj3cmRlpatnpwgsxWe1gf8uaCAzk7mt6A1UaKa0LtEqNeiq jfy/6CaQ1B0laVFWhikrnVrlkzRUz/CFD3YdxCiw7vn4fiGQAs92zkduaVe5RaSyiCXy LRrPysY+PbPukn7sS1uD+gRcQszZDY17faVp3iPOQNjY9SkA6u+uCkfCFtTaKm75GJay 7JrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724137596; x=1724742396; 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=uBFprpBCFzW7j0ztlYGU3Bm+9Kdh0TsHk9wrCucGg0A=; b=UvqnFJSlkfCDFJ7vMs2BuMRD9OOzS/MIeNoLqm/0Y5WCvgW4YNhNnpHNCQ0G6N7Bla 0i+9Y4i0JpAMr2pxkQR5czH0pMfmePD4MbhIFDLst43zj2Vh3TvCHDQ+V23hBUv4uwZI IkuzKZNbor5yPCPjMiGSav71DbuRBgp49aX2hUHdgv/9ANRRO1NWm31CEvwGSXm831qp jn9zw+GiGxHDhk+btav5KwaQdhtgdv0+Lt+HkHV96PwKvT7eD7Gbw1yx2XLjizAPESwx SfvuiWo4zUEXrIXdA4Xjgj6g88vFS0uxgXuk8acPB23kbMjSiyJcAl2UCRvHHYXZYmam m4Ig== X-Forwarded-Encrypted: i=1; AJvYcCUZBCg18quMWIJm/ntm/j+684l1d9mQfRmn41WDjfoGV0guWz5USmBaY4NnQk23oS/0mtVM66Ar+wLx9kZEb2ffyM3W6NB9r3s2tPyL X-Gm-Message-State: AOJu0YyAEt2aRafusR7EOU8e1VCzy1kYB0seM/ic+bWmCBRiF+KfPBLI s4MMNcelvQxSbZs4OnpR2MO6Z+FV6W8pd0yYBdqq+13z6qcCDbl86dUA60QFue/pAI3a4i+BfYh SpzVQxbYxUYPo5iEwn5Hor47vUrg= X-Google-Smtp-Source: AGHT+IGV+DieMuvwB7kCqI2U7dg0ZSctqrT3+gtNwfu4jhrAyPLyq2mr8WTUhPYI5/FvdHf1m4yUC8yo/3VdPP9cjeI= X-Received: by 2002:a05:651c:118a:b0:2f1:59ed:87ab with SMTP id 38308e7fff4ca-2f3be5960c5mr75377701fa.24.1724137595550; Tue, 20 Aug 2024 00:06:35 -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> <20240730142420.34a9ad7c249aecde88cd45fb@sraoss.co.jp> In-Reply-To: From: Kirill Reshke Date: Tue, 20 Aug 2024 12:06:24 +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 On Tue, 20 Aug 2024 at 02:14, Kirill Reshke wrote: > > > == Major suggestions. > > 1) At first glance, working with this IVM/IMMV infrastructure feels > really unintuitive about what servers actually do for query execution. > I do think It will be much better for user experience to add more > EXPLAIN about IVM work done inside IVM triggers. This way it is much > clearer which part is working slow, so which index should be created, > etc. > > 2) The kernel code for IVM lacks possibility to be extended for > further IVM optimizations. The one example is foreign key optimization > described here[1]. I'm not saying we should implement this within this > patchset, but we surely should pave the way for this. I don't have any > good suggestions for how to do this though. > > 3) I don't really think SQL design is good. CREATE [INCREMENTAL] M.V. > is too ad-hoc. I would prefer CREATE M.V. with (maintain_incr=true). > (reloption name is just an example). > This way we can change regular M.V. to IVM and vice versa via ALTER > M.V. SET *reloptions* - a type of syntax that is already present in > PostgreSQL core. > One little follow-up here. Why do we do prepstate visibility the way it is done? Can we instead export the snapshot in BEFORE trigger, save it somewhere and use it after? -- Best regards, Kirill Reshke