@@ -196,7 +196,7 @@ Statistics objects:
196196 "public.ab1_a_b_stats" ON a, b FROM ab1; STATISTICS 0
197197
198198ANALYZE ab1;
199- SELECT stxname, stxdndistinct, stxddependencies, stxdmcv, stxdinherit
199+ SELECT stxname, jsonb_pretty(d.stxdndistinct::text::jsonb) AS stxdndistinct, stxddependencies, stxdmcv, stxdinherit
200200 FROM pg_statistic_ext s LEFT JOIN pg_statistic_ext_data d ON (d.stxoid = s.oid)
201201 WHERE s.stxname = 'ab1_a_b_stats';
202202 stxname | stxdndistinct | stxddependencies | stxdmcv | stxdinherit
@@ -476,13 +476,43 @@ SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (
476476-- correct command
477477CREATE STATISTICS s10 ON a, b, c FROM ndistinct;
478478ANALYZE ndistinct;
479- SELECT s.stxkind, d. stxdndistinct
479+ SELECT s.stxkind, jsonb_pretty(d.stxdndistinct::text::jsonb) AS stxdndistinct
480480 FROM pg_statistic_ext s, pg_statistic_ext_data d
481481 WHERE s.stxrelid = 'ndistinct'::regclass
482482 AND d.stxoid = s.oid;
483- stxkind | stxdndistinct
484- ---------+-----------------------------------------------------
485- {d,f,m} | {"3, 4": 11, "3, 6": 11, "4, 6": 11, "3, 4, 6": 11}
483+ stxkind | stxdndistinct
484+ ---------+--------------------------
485+ {d,f,m} | [ +
486+ | { +
487+ | "ndistinct": 11,+
488+ | "attributes": [ +
489+ | 3, +
490+ | 4 +
491+ | ] +
492+ | }, +
493+ | { +
494+ | "ndistinct": 11,+
495+ | "attributes": [ +
496+ | 3, +
497+ | 6 +
498+ | ] +
499+ | }, +
500+ | { +
501+ | "ndistinct": 11,+
502+ | "attributes": [ +
503+ | 4, +
504+ | 6 +
505+ | ] +
506+ | }, +
507+ | { +
508+ | "ndistinct": 11,+
509+ | "attributes": [ +
510+ | 3, +
511+ | 4, +
512+ | 6 +
513+ | ] +
514+ | } +
515+ | ]
486516(1 row)
487517
488518-- minor improvement, make sure the ctid does not break the matching
@@ -558,13 +588,43 @@ INSERT INTO ndistinct (a, b, c, filler1)
558588 mod(i,23) || ' dollars and zero cents'
559589 FROM generate_series(1,1000) s(i);
560590ANALYZE ndistinct;
561- SELECT s.stxkind, d. stxdndistinct
591+ SELECT s.stxkind, jsonb_pretty(d.stxdndistinct::text::jsonb) AS stxdndistinct
562592 FROM pg_statistic_ext s, pg_statistic_ext_data d
563593 WHERE s.stxrelid = 'ndistinct'::regclass
564594 AND d.stxoid = s.oid;
565- stxkind | stxdndistinct
566- ---------+----------------------------------------------------------
567- {d,f,m} | {"3, 4": 221, "3, 6": 247, "4, 6": 323, "3, 4, 6": 1000}
595+ stxkind | stxdndistinct
596+ ---------+----------------------------
597+ {d,f,m} | [ +
598+ | { +
599+ | "ndistinct": 221, +
600+ | "attributes": [ +
601+ | 3, +
602+ | 4 +
603+ | ] +
604+ | }, +
605+ | { +
606+ | "ndistinct": 247, +
607+ | "attributes": [ +
608+ | 3, +
609+ | 6 +
610+ | ] +
611+ | }, +
612+ | { +
613+ | "ndistinct": 323, +
614+ | "attributes": [ +
615+ | 4, +
616+ | 6 +
617+ | ] +
618+ | }, +
619+ | { +
620+ | "ndistinct": 1000,+
621+ | "attributes": [ +
622+ | 3, +
623+ | 4, +
624+ | 6 +
625+ | ] +
626+ | } +
627+ | ]
568628(1 row)
569629
570630-- correct estimates
@@ -623,7 +683,7 @@ SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (
623683(1 row)
624684
625685DROP STATISTICS s10;
626- SELECT s.stxkind, d. stxdndistinct
686+ SELECT s.stxkind, jsonb_pretty(d.stxdndistinct::text::jsonb) AS stxdndistinct
627687 FROM pg_statistic_ext s, pg_statistic_ext_data d
628688 WHERE s.stxrelid = 'ndistinct'::regclass
629689 AND d.stxoid = s.oid;
@@ -707,13 +767,43 @@ SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (
707767
708768CREATE STATISTICS s10 (ndistinct) ON (a+1), (b+100), (2*c) FROM ndistinct;
709769ANALYZE ndistinct;
710- SELECT s.stxkind, d. stxdndistinct
770+ SELECT s.stxkind, jsonb_pretty(d.stxdndistinct::text::jsonb) AS stxdndistinct
711771 FROM pg_statistic_ext s, pg_statistic_ext_data d
712772 WHERE s.stxrelid = 'ndistinct'::regclass
713773 AND d.stxoid = s.oid;
714- stxkind | stxdndistinct
715- ---------+-------------------------------------------------------------------
716- {d,e} | {"-1, -2": 221, "-1, -3": 247, "-2, -3": 323, "-1, -2, -3": 1000}
774+ stxkind | stxdndistinct
775+ ---------+----------------------------
776+ {d,e} | [ +
777+ | { +
778+ | "ndistinct": 221, +
779+ | "attributes": [ +
780+ | -1, +
781+ | -2 +
782+ | ] +
783+ | }, +
784+ | { +
785+ | "ndistinct": 247, +
786+ | "attributes": [ +
787+ | -1, +
788+ | -3 +
789+ | ] +
790+ | }, +
791+ | { +
792+ | "ndistinct": 323, +
793+ | "attributes": [ +
794+ | -2, +
795+ | -3 +
796+ | ] +
797+ | }, +
798+ | { +
799+ | "ndistinct": 1000,+
800+ | "attributes": [ +
801+ | -1, +
802+ | -2, +
803+ | -3 +
804+ | ] +
805+ | } +
806+ | ]
717807(1 row)
718808
719809SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)');
@@ -756,13 +846,43 @@ SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b
756846
757847CREATE STATISTICS s10 (ndistinct) ON a, b, (2*c) FROM ndistinct;
758848ANALYZE ndistinct;
759- SELECT s.stxkind, d. stxdndistinct
849+ SELECT s.stxkind, jsonb_pretty(d.stxdndistinct::text::jsonb) AS stxdndistinct
760850 FROM pg_statistic_ext s, pg_statistic_ext_data d
761851 WHERE s.stxrelid = 'ndistinct'::regclass
762852 AND d.stxoid = s.oid;
763- stxkind | stxdndistinct
764- ---------+-------------------------------------------------------------
765- {d,e} | {"3, 4": 221, "3, -1": 247, "4, -1": 323, "3, 4, -1": 1000}
853+ stxkind | stxdndistinct
854+ ---------+----------------------------
855+ {d,e} | [ +
856+ | { +
857+ | "ndistinct": 221, +
858+ | "attributes": [ +
859+ | 3, +
860+ | 4 +
861+ | ] +
862+ | }, +
863+ | { +
864+ | "ndistinct": 247, +
865+ | "attributes": [ +
866+ | 3, +
867+ | -1 +
868+ | ] +
869+ | }, +
870+ | { +
871+ | "ndistinct": 323, +
872+ | "attributes": [ +
873+ | 4, +
874+ | -1 +
875+ | ] +
876+ | }, +
877+ | { +
878+ | "ndistinct": 1000,+
879+ | "attributes": [ +
880+ | 3, +
881+ | 4, +
882+ | -1 +
883+ | ] +
884+ | } +
885+ | ]
766886(1 row)
767887
768888SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b');
0 commit comments