0004-shorten_names-refresh_docs-tests-20230121.patch

text/plain

Filename: 0004-shorten_names-refresh_docs-tests-20230121.patch
Type: text/plain
Part: 3
Message: Re: pg_stats and range statistics

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
Series: patch 0004
File+
doc/src/sgml/catalogs.sgml 14 6
src/backend/catalog/system_views.sql 2 2
src/test/regress/expected/rules.out 15 7
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index c8bd84c56e..e0851c52b4 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -9647,7 +9647,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
 
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>empty_range_frac</structfield> <type>float4</type>
+       <structfield>range_empty_frac</structfield> <type>float4</type>
       </para>
       <para>
        Fraction of column entries whose values are empty ranges.
@@ -9657,13 +9657,21 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
 
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>range_bounds_histograms</structfield> <type>anyarray</type>
+       <structfield>range_lower_histogram</structfield> <type>anyarray</type>
       </para>
       <para>
-       Histograms of lower and upper bounds of non-empty, non-null ranges,
-       combined into a single array of range values. The lower and upper bounds
-       of each value correspond to the histograms of lower and upper bounds
-       respectively. (Null for non-range types.)
+       A histogram of lower bounds of non-empty and non-null range values.
+       (Null for non-range types.)
+      </para></entry>
+     </row>
+
+     <row>
+      <entry role="catalog_table_entry"><para role="column_definition">
+       <structfield>range_upper_histogram</structfield> <type>anyarray</type>
+      </para>
+      <para>
+       A histogram of upper bounds of non-empty and non-null range values.
+       (Null for non-range types.)
       </para></entry>
      </row>
     </tbody>
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index ac99d41f80..b3b9e64ae2 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -264,14 +264,14 @@ CREATE VIEW pg_stats WITH (security_barrier) AS
             WHEN stakind3 = 7 THEN ranges_lower_bounds(stavalues3)
             WHEN stakind4 = 7 THEN ranges_lower_bounds(stavalues4)
             WHEN stakind5 = 7 THEN ranges_lower_bounds(stavalues5)
-            END AS range_lower_bounds_histograms,
+            END AS range_lower_histogram,
         CASE
             WHEN stakind1 = 7 THEN ranges_upper_bounds(stavalues1)
             WHEN stakind2 = 7 THEN ranges_upper_bounds(stavalues2)
             WHEN stakind3 = 7 THEN ranges_upper_bounds(stavalues3)
             WHEN stakind4 = 7 THEN ranges_upper_bounds(stavalues4)
             WHEN stakind5 = 7 THEN ranges_upper_bounds(stavalues5)
-            END AS range_upper_bounds_histograms
+            END AS range_upper_histogram
     FROM pg_statistic s JOIN pg_class c ON (c.oid = s.starelid)
          JOIN pg_attribute a ON (c.oid = attrelid AND attnum = s.staattnum)
          LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index ced5933271..26087dfdf5 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -2452,15 +2452,23 @@ pg_stats| SELECT n.nspname AS schemaname,
             WHEN (s.stakind4 = 6) THEN s.stanumbers4[1]
             WHEN (s.stakind5 = 6) THEN s.stanumbers5[1]
             ELSE NULL::real
-        END AS empty_range_frac,
+        END AS range_empty_frac,
         CASE
-            WHEN (s.stakind1 = 7) THEN s.stavalues1
-            WHEN (s.stakind2 = 7) THEN s.stavalues2
-            WHEN (s.stakind3 = 7) THEN s.stavalues3
-            WHEN (s.stakind4 = 7) THEN s.stavalues4
-            WHEN (s.stakind5 = 7) THEN s.stavalues5
+            WHEN (s.stakind1 = 7) THEN ranges_lower_bounds(s.stavalues1)
+            WHEN (s.stakind2 = 7) THEN ranges_lower_bounds(s.stavalues2)
+            WHEN (s.stakind3 = 7) THEN ranges_lower_bounds(s.stavalues3)
+            WHEN (s.stakind4 = 7) THEN ranges_lower_bounds(s.stavalues4)
+            WHEN (s.stakind5 = 7) THEN ranges_lower_bounds(s.stavalues5)
             ELSE NULL::anyarray
-        END AS range_bounds_histograms
+        END AS range_lower_histogram,
+        CASE
+            WHEN (s.stakind1 = 7) THEN ranges_upper_bounds(s.stavalues1)
+            WHEN (s.stakind2 = 7) THEN ranges_upper_bounds(s.stavalues2)
+            WHEN (s.stakind3 = 7) THEN ranges_upper_bounds(s.stavalues3)
+            WHEN (s.stakind4 = 7) THEN ranges_upper_bounds(s.stavalues4)
+            WHEN (s.stakind5 = 7) THEN ranges_upper_bounds(s.stavalues5)
+            ELSE NULL::anyarray
+        END AS range_upper_histogram
    FROM (((pg_statistic s
      JOIN pg_class c ON ((c.oid = s.starelid)))
      JOIN pg_attribute a ON (((c.oid = a.attrelid) AND (a.attnum = s.staattnum))))