On Tue, Nov 11, 2025 at 11:14 PM jian he <jian.universality@gmail.com> wrote:
>
> On Tue, Nov 11, 2025 at 4:07 PM Michael Paquier <michael@paquier.xyz> wrote:
> > I've rebased the full set using the new structure. 0001~0004 are
> > clean. 0005~ need more work and analysis, but that's a start.
hi.
+Datum
+pg_ndistinct_out(PG_FUNCTION_ARGS)
+
+
+ appendStringInfo(&str, "], \"" PG_NDISTINCT_KEY_NDISTINCT "\": %d}",
+ (int) item.ndistinct);
I’m a bit confused about the part above,
item.ndistinct is double type, we just cast it to int type?
after apply 0004, the below in doc/src/sgml/perform.sgml also need to change?
<programlisting>
CREATE STATISTICS stts (dependencies) ON city, zip FROM zipcodes;
ANALYZE zipcodes;
SELECT stxname, stxkeys, stxddependencies
FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid)
WHERE stxname = 'stts';
stxname | stxkeys | stxddependencies
---------+---------+------------------------------------------
stts | 1 5 | {"1 => 5": 1.000000, "5 => 1": 0.423130}
(1 row)
</programlisting>
Do you think it's worth the trouble to have two separate
appendStringInfoChar for ``{}``?
for example in loop ``for (i = 0; i < ndist->nitems; i++)``. we can change to:
appendStringInfoChar(&str, '{');
appendStringInfo(&str, "\"" PG_NDISTINCT_KEY_ATTRIBUTES "\": [%d",
item.attributes[0]);
for (int j = 1; j < item.nattributes; j++)
appendStringInfo(&str, ", %d", item.attributes[j]);
appendStringInfo(&str, "], \"" PG_NDISTINCT_KEY_NDISTINCT "\": %d",
(int) item.ndistinct);
appendStringInfoChar(&str, '}');
--
jian
https://www.enterprisedb.com/