public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tomas Vondra <[email protected]>
To: Zhihong Yu <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Nikita Glukhov <[email protected]>
Cc: Mahendra Thalor <[email protected]>
Cc: Oleg Bartunov <[email protected]>
Subject: Re: Collecting statistics about contents of JSONB columns
Date: Thu, 6 Jan 2022 20:22:33 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CALNJ-vT8qwNd46Qf+1hSiR+9rz=Sv9w-PQabiwbwM-=CgixyZw@mail.gmail.com>
References: <[email protected]>
<CALNJ-vQ7p=ZaZ=prwU=tV3FqXhF6CrW+u2Wve3iJVn2wGMBS8A@mail.gmail.com>
<CALNJ-vT8qwNd46Qf+1hSiR+9rz=Sv9w-PQabiwbwM-=CgixyZw@mail.gmail.com>
On 1/1/22 22:16, Zhihong Yu wrote:
> Hi,
>
> +static JsonPathStats
> +jsonStatsFindPathStats(JsonStats jsdata, char *path, int pathlen)
>
> Stats appears twice in the method name. I think findJsonPathStats()
> should suffice.
> It should check `if (jsdata->nullfrac >= 1.0)`
> as jsonStatsGetPathStatsStr does.
>
> +JsonPathStats
> +jsonStatsGetPathStatsStr(JsonStats jsdata, const char *subpath, int
> subpathlen)
>
> This func can be static, right ?
> I think findJsonPathStatsWithPrefix() would be a better name for the func.
>
> + * XXX Doesn't this need ecape_json too?
> + */
> +static void
> +jsonPathAppendEntryWithLen(StringInfo path, const char *entry, int len)
> +{
> + char *tmpentry = pnstrdup(entry, len);
> + jsonPathAppendEntry(path, tmpentry);
>
> ecape_json() is called within jsonPathAppendEntry(). The XXX comment can
> be dropped.
>
> +jsonPathStatsGetArrayIndexSelectivity(JsonPathStats pstats, int index)
>
> It seems getJsonSelectivityWithArrayIndex() would be a better name.
>
Thanks. I'll think about the naming changes.
> + sel = scalarineqsel(NULL, operator,
> + operator == JsonbGtOperator ||
> + operator == JsonbGeOperator,
> + operator == JsonbLeOperator ||
> + operator == JsonbGeOperator,
>
> Looking at the comment for scalarineqsel():
>
> * scalarineqsel - Selectivity of "<", "<=", ">", ">=" for scalars.
> *
> * This is the guts of scalarltsel/scalarlesel/scalargtsel/scalargesel.
> * The isgt and iseq flags distinguish which of the four cases apply.
>
> It seems JsonbLtOperator doesn't appear in the call, can I ask why ?
>
Because the scalarineqsel signature is this
scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, bool iseq,
Oid collation,
VariableStatData *vardata, Datum constval,
Oid consttype)
so
/* is it greater or greater-or-equal */
isgt = operator == JsonbGtOperator ||
operator == JsonbGeOperator
/* is it equality? */
iseq = operator == JsonbLeOperator ||
operator == JsonbGeOperator,
So I think this is correct. A comment explaining this would be nice.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
view thread (3+ messages)
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Collecting statistics about contents of JSONB columns
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox