Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jspEL-0000Lz-Ae for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jul 2020 15:09:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jspEK-00056f-7u for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jul 2020 15:09:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jspEK-00056Y-14 for pgsql-hackers@lists.postgresql.org; Tue, 07 Jul 2020 15:09:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jspEH-0004D4-2i for pgsql-hackers@lists.postgresql.org; Tue, 07 Jul 2020 15:09:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 067F9nlc1522795; Tue, 7 Jul 2020 11:09:49 -0400 From: Tom Lane To: Robert Haas cc: Anastasia Lubennikova , PostgreSQL Hackers Subject: Re: Proposal: Automatic partition creation In-reply-to: References: <7fec3abb-c663-c0d2-8452-a46141be6d4a@postgrespro.ru> <1378901.1594051837@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Tue, 07 Jul 2020 10:22:47 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1522793.1594134589.1@sss.pgh.pa.us> Date: Tue, 07 Jul 2020 11:09:49 -0400 Message-ID: <1522794.1594134589@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Mon, Jul 6, 2020 at 12:10 PM Tom Lane wrote: >> We did indeed solve this in connection with window functions, cf >> 0a459cec9. I may be misunderstanding what the problem is here, >> but I think trying to reuse that infrastructure might help. > Ah, nice. I didn't realize that we'd added that. But I'm not sure that > it helps here, because I think we need to compute the end of the > range, not just test whether something is in a range. Yeah, I was thinking about that later, and I agree that the in_range support function doesn't quite do the job. But we could expand on the principle, and register addition (and subtraction?) functions as btree support functions under the same rules as for in_range functions. The reason in_range isn't just addition is that we wanted it to be able to give correct answers even in cases where addition would overflow. That's still valid for that use-case, but it doesn't apply here. So it'd be something like "btree support function 4, registered under amproclefttype x and amprocrighttype y, must have the signature plus(x, y) returns x and it gives results compatible with the opfamily's ordering of type x". Similarly for subtraction if we think we need that. I'm not sure if we need a formal notion of what "compatible results" means, but it probably would be something like "if x < z according to the opfamily sort ordering, then plus(x, y) < plus(z, y) for any given y". Now this falls to the ground when y is a weird value like Inf or NaN, but we'd want to exclude those as partitioning values anyway. Do we also need some datatype-independent way of identifying such "weird values"? regards, tom lane