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.96) (envelope-from ) id 1wJl56-000E7N-1q for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 04:38:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wJl55-005VnI-0h for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 04:38:55 +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.96) (envelope-from ) id 1wJl54-005VnA-2y for pgsql-hackers@lists.postgresql.org; Mon, 04 May 2026 04:38:54 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wJl52-000000005nO-27fZ for pgsql-hackers@postgresql.org; Mon, 04 May 2026 04:38:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 6444ccX2117987; Mon, 4 May 2026 00:38:39 -0400 From: Tom Lane To: Andy Fan cc: David Rowley , pgsql-hackers Subject: Re: Make printtup a bit faster In-reply-to: <877bpk7dyg.fsf@163.com> References: <87wmjzfz0h.fsf@163.com> <87bk1aj2go.fsf@163.com> <877bpk7dyg.fsf@163.com> Comments: In-reply-to Andy Fan message dated "Sun, 03 May 2026 22:41:27 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <117985.1777869518.1@sss.pgh.pa.us> Date: Mon, 04 May 2026 00:38:38 -0400 Message-ID: <117986.1777869518@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andy Fan writes: > You understood me correctly and I thought we should maintain one version > two years ago, so I tried to implement this idea today. The first issue I > want to talk about now how to define the function protocol in SQL, take > int4out for example: > master: cstring int4out(integer); > New protocol: void int4out(integer, internal). and the internal is > StringInfo acutally. > The direct impaction would be: > master support: > postgres=# select int4out(8); > int4out > --------- > 8 > (1 row) > After our change, user could not invoke any {type}out function anymore > in SQL since it takes 'internal' as an agrument. I am not sure if people > would write SQL like this, but it'd be good to have a talk about this. I think you missed the point of what I said two years ago: you will never be able to remove the existing output function API, nor the per-datatype functions that implement that API. Even if we were willing to convert every last one of the in-core callers and callees, doing that would break too much non-core code. So the above example is never going to stop working. We can consider implementing a new datatype output API alongside the existing one. But it'd likely not be callable from SQL, so the question of SQL compatibility is moot. My own guess is that even if we built a new API, only a fairly small number of datatypes would find it worth the trouble to support. The potential win seems clear for, say, textout: there's really no computation to do, only data copying, so halving the amount of copying is attractive. But I bet you won't measure much percentage improvement for numeric_out or point_out. This line of thought suggests that maybe some special-purpose hack would be a better answer than defining a new datatype API. It's hard to tell without some concrete performance numbers, which are sadly lacking in this thread. regards, tom lane