Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ic0wj-00006S-TR for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Dec 2019 05:42:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ic0wi-0006Ik-Mt for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Dec 2019 05:42:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ic0wi-0006IU-Di for pgsql-hackers@lists.postgresql.org; Tue, 03 Dec 2019 05:42:00 +0000 Received: from sraihb2.sra.co.jp ([202.32.10.6]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ic0we-0000Cm-FI for pgsql-hackers@postgresql.org; Tue, 03 Dec 2019 05:42:00 +0000 Received: from srascf.sra.co.jp (srascf [133.137.8.80]) by sraihb2.sra.co.jp (Postfix) with ESMTP id C6DD02A160B for ; Tue, 3 Dec 2019 14:41:53 +0900 (JST) Received: from srascb.sra.co.jp (unknown [133.137.8.65]) by srascf.sra.co.jp with smtp id 5d98_1edf_c2d83d01_1967_4818_bbf9_60f6ca9b3025; Tue, 03 Dec 2019 14:41:53 +0900 Received: from sranhm.sra.co.jp (osspc25 [133.137.174.97]) by srascb.sra.co.jp (Postfix) with ESMTP id 972852D6943 for ; Tue, 3 Dec 2019 14:41:53 +0900 (JST) Received: from yugon-CFSV7-1 (dhcp-175-194.sra.co.jp [133.137.175.194]) by sranhm.sra.co.jp (Postfix) with SMTP id 75AD9A125D; Tue, 3 Dec 2019 14:41:53 +0900 (JST) Date: Tue, 3 Dec 2019 14:41:22 +0900 From: Yugo Nagata To: Alvaro Herrera Cc: Tatsuo Ishii , pgsql-hackers@postgresql.org, hoshiai@sraoss.co.jp, thomas.munro@gmail.com, kgrittn@gmail.com Subject: Re: Implementing Incremental View Maintenance Message-Id: <20191203144122.ffd8d5de5f1f1bc1e1f02cc2@sraoss.co.jp> In-Reply-To: <20191202164840.GA8271@alvherre.pgsql> References: <20191202154208.b613271eff61bc34b570d009@sraoss.co.jp> <20191202164840.GA8271@alvherre.pgsql> X-Mailer: Sylpheed 3.5.1 (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: Precedence: bulk On Mon, 2 Dec 2019 13:48:40 -0300 Alvaro Herrera wrote: > On 2019-Dec-02, Yugo Nagata wrote: > > > On Mon, 02 Dec 2019 10:36:36 +0900 (JST) > > Tatsuo Ishii wrote: > > > > > >> One thing pending in this development line is how to catalogue aggregate > > > >> functions that can be used in incrementally-maintainable views. > > > >> I saw a brief mention somewhere that the devels knew it needed to be > > > >> done, but I don't see in the thread that they got around to doing it. > > > >> Did you guys have any thoughts on how it can be represented in catalogs? > > > >> It seems sine-qua-non ... > > > > > In the first option, we support only built-in aggregates which we know able > > > > to handle correctly. Supported aggregates can be identified using their OIDs. > > > > User-defined aggregates are not supported. I think this is the simplest and > > > > easiest way. > > > > > > I think this is enough for the first cut of IVM. So +1. > > > > If there is no objection, I will add the check of aggregate functions > > by this way. Thanks. > > The way I imagine things is that there's (one or more) new column in > pg_aggregate that links to the operator(s) (or function(s)?) that > support incremental update of the MV for that aggregate function. Is > that what you're proposing? The way I am proposing above is using OID to check if a aggregate can be used in IVM. This allows only a part of built-in aggreagete functions. This way you mentioned was proposed as one of options as following. On Fri, 29 Nov 2019 17:33:28 +0900 Yugo Nagata wrote: > Third, we can add a new attribute to pg_aggregate which shows if each > aggregate can be used in IVM. We don't need to use names or OIDs list of > supported aggregates although we need modification of the system catalogue. > > Regarding pg_aggregate, now we have aggcombinefn attribute for supporting > partial aggregation. Maybe we could use combine functions to calculate new > aggregate values in IVM when tuples are inserted into a table. However, in > the context of IVM, we also need other function used when tuples are deleted > from a table, so we can not use partial aggregation for IVM in the current > implementation. This might be another option to implement "inverse combine > function"(?) for IVM, but I am not sure it worth. If we add "inverse combine function" in pg_aggregate that takes two results of aggregating over tuples in a view and tuples in a delta, and produces a result of aggregating over tuples in the view after tuples in the delta are deleted from this, it would allow to calculate new aggregate values in IVM using aggcombinefn together when the aggregate function provides both functions. Another idea is to use support functions for moving-aggregate mode which are already provided in pg_aggregate. However, in this case, we have to apply tuples in the delta to the view one by one instead of applying after aggregating tuples in the delta. In both case, we can not use these support functions in SQL via SPI because the type of some aggregates is internal. We have to alter the current apply_delta implementation if we adopt a way using these support functions. Instead, we also can add support functions for IVM independent to partial aggregate or moving-aggregate. Maybe this is also one of options. Regards, Yugo Nagata -- Yugo Nagata