postgresql/src/backend
Nathan Bossart dc3f9bc549 Micro-optimize JSONTYPE_NUMERIC code path in json.c.
This commit does the following:

* In datum_to_json_internal(), the call to IsValidJsonNumber() is
  replaced with simplified validation code.  This avoids an extra
  call to strlen() in this path, and it avoids validating the
  entire string (which is okay since we know we're dealing with a
  numeric data type's output).

* In datum_to_json_internal(), the call to escape_json() in the
  JSONTYPE_NUMERIC path is replaced with code that just surrounds
  the string with quotes.  In passing, some other nearby calls to
  appendStringInfo() have been replaced with similar code to avoid
  unnecessary calls to vsnprintf().

* In composite_to_json(), the length of the separator is now
  determined at compile time to avoid unnecessary calls to
  strlen().

On my machine, this speeds up a benchmark for the proposed COPY TO
(FORMAT json) command with many integers by upwards of 20%.  There
are likely other code paths that could be given a similar
treatment, but that is left as a future exercise.

Reviewed-by: Jeff Davis, Tom Lane, David Rowley, John Naylor
Discussion: https://postgr.es/m/20231207231251.GB3359478%40nathanxps13
2023-12-08 13:39:08 -06:00
..
access Optimize nbtree backward scan boundary cases. 2023-12-08 11:05:17 -08:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Change how a base backup decides which files have checksums. 2023-11-14 10:51:05 -05:00
bootstrap Remove distprep 2023-11-06 15:18:04 +01:00
catalog Allow parallel CREATE INDEX for BRIN indexes 2023-12-08 18:15:26 +01:00
commands Don't try to open visibilitymap when analyzing a foreign table 2023-12-08 09:16:21 +02:00
executor Verify that attribute counts match in ExecCopySlot 2023-12-07 21:28:24 +13:00
foreign Improve "user mapping not found" error message 2023-11-30 05:34:28 +01:00
jit Make ResourceOwners more easily extensible. 2023-11-08 13:30:50 +02:00
lib Make binaryheap available to frontend code. 2023-09-18 12:18:33 -07:00
libpq Apply quotes more consistently to GUC names in logs 2023-11-30 14:11:45 +09:00
main Remove obsolete defense against strxfrm() bugs. 2023-04-20 13:20:14 +12:00
nodes Remove distprep 2023-11-06 15:18:04 +01:00
optimizer Fix comment about ressortgrouprefs being unique in setop plans. 2023-11-28 14:15:14 +02:00
parser Clean up usage of bison precedence for non-operator keywords. 2023-11-28 13:32:15 -05:00
partitioning Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
po Translation updates 2023-08-07 12:39:30 +02:00
port Remove distprep 2023-11-06 15:18:04 +01:00
postmaster Remove some unnecessary #includes of postmaster/interrupt.h 2023-12-08 13:19:37 +02:00
regex Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
replication Fix indentation 2023-12-05 15:54:59 +01:00
rewrite Add TupleDescGetDefault() 2023-09-27 18:52:40 +01:00
snowball Remove distprep 2023-11-06 15:18:04 +01:00
statistics Retire MemoryContextResetAndDeleteChildren() macro. 2023-11-15 13:42:30 -06:00
storage Rename ShmemVariableCache to TransamVariables 2023-12-08 09:47:15 +02:00
tcop Add support for REINDEX in event triggers 2023-12-04 09:53:49 +09:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Micro-optimize JSONTYPE_NUMERIC code path in json.c. 2023-12-08 13:39:08 -06:00
.gitignore
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build Add win32ver data to meson-built postgres.exe. 2023-06-12 07:40:38 -07:00
nls.mk Remove distprep 2023-11-06 15:18:04 +01:00