pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Lepikhov <lepihov@gmail.com>
To: shihao zhong <zhong950419@gmail.com>
To: Priyanka S <developerette@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: [PATCH] Planner support function for generate_subscripts()
Date: Tue, 8 Sep 2026 12:07:48 +0200
Message-ID: <fbf72e54-8db2-4377-8ec5-3d8e1deca75d@gmail.com> (raw)
In-Reply-To: <CAGRkXqRJ0AbNGeH8sjsq5rG_Ov_dpzg2Rifb2U=-0Xre1ZpH9w@mail.gmail.com>
References: <CAGRkXqQ6BLCkEBBC2OC_bvEaUPTg+z+2-euiJKKvAxgA7o1EAA@mail.gmail.com>
	<CA+Db6gYaLov7zfWTgqgyp35YpQ3hs6EdxfC=1fveA3tC25ZR-A@mail.gmail.com>
	<CAGRkXqRJ0AbNGeH8sjsq5rG_Ov_dpzg2Rifb2U=-0Xre1ZpH9w@mail.gmail.com>

On 08/09/2026 03:21, shihao zhong wrote:
> * A dimension above the first is asked for on an array that is not a
>   constant.  One dimension of an array is never longer than the whole
>   array, so a large number is wrong here.
> 
> 1000 fits neither case.
> 
> I kept 0002 as its own patch.  It only changes a number in the catalog,
> and 0001 does not need it.  If people do not agree on the number, 0001
> can still go in.
I'd say that detecting the estimate_array_length's default value for the rows
number and returning constant 1000 as used before might make life of engineers
easier and query plans more stable during upgrade.
Hence, maybe it makes sense to follow the way of group-by estimations -
introduce something like one more 'isdefault' parameter to the
estimate_array_length?

Basically, this code looks good. But I'd like to see more assertions: if
something will be changed at the functions itself it would more quickly detect
issues in the prosupport routine. For example:
- Assert(req->root != NULL);
- Type of arg2
- Potentially, no more than 3 arguments of the function
- Maybe hard oid check on F_GENERATE_SUBSCRIPTS / F_GENERATE_SUBSCRIPTS_NODIR

This topic also raises the question of the practical usability of the average
total number of elements in an array column. Your tests highlight a gap in
estimates for more than two dimensions.

regards, Andrei Lepikhov,
pgEdge






view thread (8+ messages)  latest in thread

Message-ID: <fbf72e54-8db2-4377-8ec5-3d8e1deca75d@gmail.com>
Permalink:  ../fbf72e54-8db2-4377-8ec5-3d8e1deca75d@gmail.com/
Also on:    postgresql.org/message-id/fbf72e54-8db2-4377-8ec5-3d8e1deca75d@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: lepihov@gmail.com, zhong950419@gmail.com, developerette@gmail.com
  Subject: Re: [PATCH] Planner support function for generate_subscripts()
  In-Reply-To: <fbf72e54-8db2-4377-8ec5-3d8e1deca75d@gmail.com>
  References: <CAGRkXqQ6BLCkEBBC2OC_bvEaUPTg+z+2-euiJKKvAxgA7o1EAA@mail.gmail.com> <CA+Db6gYaLov7zfWTgqgyp35YpQ3hs6EdxfC=1fveA3tC25ZR-A@mail.gmail.com> <CAGRkXqRJ0AbNGeH8sjsq5rG_Ov_dpzg2Rifb2U=-0Xre1ZpH9w@mail.gmail.com> <fbf72e54-8db2-4377-8ec5-3d8e1deca75d@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox