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 1pMnlP-0006iJ-MS for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Jan 2023 10:21:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pMnlO-0001aY-9U for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Jan 2023 10:21:18 +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 1pMnlN-0001aO-VY for pgsql-hackers@lists.postgresql.org; Tue, 31 Jan 2023 10:21:17 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMnlL-0005QN-NT for pgsql-hackers@postgresql.org; Tue, 31 Jan 2023 10:21:17 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 7BED3581D95; Tue, 31 Jan 2023 05:21:14 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 31 Jan 2023 05:21:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1675160474; x= 1675167674; bh=GLfJrhC1oIxtRj5fvPqLW53+O6EB7xSVjxgg4Av0G9k=; b=E HlqHoXmvMIc57aUoTDzcDNVoQasMU9YUaVHD4qKmmzpnACiUmPpHN9gG/AfJMOGF NqPqvA9YS+4e7oZe+nLhjYoBq5zdZuq+SmlGncUE9pKblUinhhhuWliKkadEofBA zQaudRid9CqEM4hNwB3+t/YxMe+dBUnEXgJPHb0mwt9OpGBIuDXG4iFsvBIaEWIA TN0oQVG0d7saB2edvQW4gJnRL+5ChKw0/GE2h+VWBA53CmAAU3T4ItomYCAkI2XC OBqSRcGJJcNQ3D3vWtVTfTwlJeugZww13njPPhPuu73xbkyshx2zmX0M0K7NWSfU 4B7mP66ZIeKCxwHGkYOFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudefgedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnth gvrhhprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeehleffgeegudejteei hfelteduvdeifffhffdvjedvffegjeekudeludehudeifeenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghu thesvghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 31 Jan 2023 05:21:13 -0500 (EST) Message-ID: <64cf77f9-4af6-7585-e72f-86816b7f7704@enterprisedb.com> Date: Tue, 31 Jan 2023 11:21:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Named Operators Content-Language: en-US To: Matthias van de Meent Cc: Gurjeet Singh , Postgres Hackers References: <5d454cec-1bb5-2131-f3d8-f431cf29b7eb@enterprisedb.com> From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 27.01.23 16:34, Matthias van de Meent wrote: > On Fri, 27 Jan 2023 at 16:26, Peter Eisentraut > wrote: >> >> On 12.01.23 14:55, Matthias van de Meent wrote: >>>> Matter of taste, I guess. But more importantly, defining an operator >>>> gives you many additional features that the planner can use to >>>> optimize your query differently, which it can't do with functions. See >>>> the COMMUTATOR, HASHES, etc. clause in the CREATE OPERATOR command. >>> I see. Wouldn't it be better then to instead make it possible for the >>> planner to detect the use of the functions used in operators and treat >>> them as aliases of the operator? Or am I missing something w.r.t. >>> differences between operator and function invocation? >>> >>> E.g. indexes on `int8pl(my_bigint, 1)` does not match queries for >>> `my_bigint + 1` (and vice versa), while they should be able to support >>> that, as OPERATOR(pg_catalog.+(int8, int8)) 's function is int8pl. >> >> I have been thinking about something like this for a long time. >> Basically, we would merge pg_proc and pg_operator internally. Then, all >> the special treatment for operators would also be available to >> two-argument functions. > > And single-argument functions in case of prefix operators, right? Right. (The removal of postfix operators is helpful to remove ambiguity here.)