Re: [PATCH] pg_convert improvement
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>
To: Yurii Rashkovskii <yrashk@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2023-11-24T14:26:00Z
Lists: pgsql-hackers
Hi, On 11/24/23 3:05 PM, Yurii Rashkovskii wrote: > Hi, > > I propose a patch that ensures `pg_convert` doesn't allocate and copy data when no conversion is done. It is an unnecessary overhead, especially when such conversions are done frequently and for large values. > +1 for the patch, I think the less is done the better. > > Happy to hear any feedback! > The patch is pretty straightforward, I just have one remark: + /* if no actual conversion happened, return the original string */ + /* (we are checking pointers to strings instead of encodings because + `pg_do_encoding_conversion` above covers more cases than just + encoding equality) */ I think this could be done in one single comment and follow the preferred style for multi-line comment, see [1]. [1]: https://www.postgresql.org/docs/current/source-format.html Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
Commits
-
Teach convert() and friends to avoid copying when possible.
- b14b1eb4da4c 17.0 landed