pgsql: Improve the implementation of information_schema._pg_expandarray

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve the implementation of information_schema._pg_expandarray
Date: 2023-12-27 20:55:54
Message-ID: E1rIawT-00CCqw-M2@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve the implementation of information_schema._pg_expandarray().

This function was originally coded with a handmade expansion
of the array subscripts. We can do it a little faster and far
more legibly today, by using unnest() WITH ORDINALITY.

While at it, let's apply the rowcount estimation support that exists
for the underlying unnest() function: reduce the default ROWS estimate
to 100 and attach array_unnest_support. I'm not sure that
array_unnest_support can do anything useful today with the call sites
that exist in information_schema, but it can't hurt, and the existing
default rowcount of 1000 is surely much too high for any of these
cases.

The psql.sql regression script is using _pg_expandarray() as a
test case for \sf+. While we could keep doing so, the new one-line
function body makes a poor test case for \sf+ row-numbering, so
switch it to print another information_schema function.

Discussion: https://postgr.es/m/1424303.1703355485@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/58054de2d0847c09ef091956f72ae5e9fb9a176e

Modified Files
--------------
src/backend/catalog/information_schema.sql | 7 ++----
src/backend/utils/adt/arrayfuncs.c | 3 +++
src/include/catalog/catversion.h | 2 +-
src/test/regress/expected/psql.out | 40 ++++++++++++++++--------------
src/test/regress/sql/psql.sql | 4 +--
5 files changed, 30 insertions(+), 26 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2023-12-28 11:10:07 pgsql: doc: Mention AttributeRelationId in FDW validator function descr
Previous Message Tom Lane 2023-12-27 18:53:25 pgsql: Doc: specify aclitem syntax more clearly.