agora inbox for [email protected]
help / color / mirror / Atom feed[PATCH 2/2] fixup: rename defined to requested
36+ messages / 4 participants
[nested] [flat]
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH 2/2] fixup: rename defined to requested
@ 2021-01-08 23:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tomas Vondra @ 2021-01-08 23:56 UTC (permalink / raw)
---
src/bin/psql/describe.c | 10 +--
src/test/regress/expected/stats_ext.out | 90 ++++++++++++-------------
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 46f54199fb..83084f79d0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4440,10 +4440,10 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN es.stxndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN es.stxdependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"));
@@ -4452,13 +4452,13 @@ listExtendedStats(const char *pattern, bool verbose)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN esd.stxdndistinct IS NOT NULL THEN 'built' \n"
- " WHEN 'd' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'd' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxddependencies IS NOT NULL THEN 'built' \n"
- " WHEN 'f' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'f' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\", \n"
"CASE WHEN esd.stxdmcv IS NOT NULL THEN 'built' \n"
- " WHEN 'm' = any(es.stxkind) THEN 'defined' \n"
+ " WHEN 'm' = any(es.stxkind) THEN 'requested' \n"
"END AS \"%s\"",
gettext_noop("Ndistinct"),
gettext_noop("Dependencies"),
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index 8c8a0afcf6..b3ae4de185 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -1741,9 +1741,9 @@ create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_
insert into stts_t1 select i,i from generate_series(1,100) i;
analyze stts_t1;
\dX
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
-----------+------------------------+--------------------------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+----------+------------------------+--------------------------------------+-----------+--------------+-----------
public | func_deps_stat | a, b, c FROM functional_dependencies | | built |
public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built
public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built
@@ -1751,70 +1751,70 @@ analyze stts_t1;
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested
tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built
(12 rows)
\dX stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+--------+-------------------+-----------+--------------+---------
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+--------+-------------------+-----------+--------------+-----------
public | stts_1 | a, b FROM stts_t1 | built | |
public | stts_2 | a, b FROM stts_t1 | built | built |
public | stts_3 | a, b FROM stts_t1 | built | built | built
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested
(4 rows)
\dX *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV
---------+-----------+-------------------------------+-----------+--------------+---------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV
+--------+-----------+-------------------------------+-----------+--------------+-----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested
(1 row)
\dX+
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
-----------+------------------------+--------------------------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
- public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
- public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
- public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s1 | stts_foo | col1, col2 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
- tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+----------+------------------------+--------------------------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | func_deps_stat | a, b, c FROM functional_dependencies | | built | | | 106 bytes |
+ public | mcv_lists_arrays_stats | a, b, c FROM mcv_lists_arrays | | | built | | | 24 kB
+ public | mcv_lists_bool_stats | a, b, c FROM mcv_lists_bool | | | built | | | 386 bytes
+ public | mcv_lists_stats | a, b, d FROM mcv_lists | | | built | | | 294 bytes
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s1 | stts_foo | col1, col2 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
+ tststats | priv_test_stats | a, b FROM tststats.priv_test_tbl | | | built | | | 686 bytes
(12 rows)
\dX+ stts_?
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+--------+-------------------+-----------+--------------+---------+----------------+-------------------+------------
- public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
- public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
- public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
- public | stts_4 | b, c FROM stts_t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+--------+-------------------+-----------+--------------+-----------+----------------+-------------------+------------
+ public | stts_1 | a, b FROM stts_t1 | built | | | 13 bytes | |
+ public | stts_2 | a, b FROM stts_t1 | built | built | | 13 bytes | 40 bytes |
+ public | stts_3 | a, b FROM stts_t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
+ public | stts_4 | b, c FROM stts_t2 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(4 rows)
\dX+ *stts_hoge
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
---------+-----------+-------------------------------+-----------+--------------+---------+----------------+-------------------+----------
- public | stts_hoge | col1, col2, col3 FROM stts_t3 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+--------+-----------+-------------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ public | stts_hoge | col1, col2, col3 FROM stts_t3 | requested | requested | requested | 0 bytes | 0 bytes | 0 bytes
(1 row)
\dX+ stts_s2.stts_yama
- List of extended statistics
- Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
----------+-----------+-------------------------+-----------+--------------+---------+----------------+-------------------+----------
- stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | defined | defined | | 0 bytes | 0 bytes
+ List of extended statistics
+ Schema | Name | Definition | Ndistinct | Dependencies | MCV | Ndistinct_size | Dependencies_size | MCV_size
+---------+-----------+-------------------------+-----------+--------------+-----------+----------------+-------------------+----------
+ stts_s2 | stts_yama | col1, col3 FROM stts_t3 | | requested | requested | | 0 bytes | 0 bytes
(1 row)
drop table stts_t1, stts_t2, stts_t3;
--
2.26.2
--------------B0278A9E952F6668D2DBEBA1--
^ permalink raw reply [nested|flat] 36+ messages in thread
* Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-12 09:19 David Rowley <[email protected]>
0 siblings, 2 replies; 36+ messages in thread
From: David Rowley @ 2022-10-12 09:19 UTC (permalink / raw)
To: PostgreSQL Developers <[email protected]>
Over on [1], Klint highlights a query with a DISTINCT which is a
little sub-optimal in PostgreSQL. ISTM that in cases where all
DISTINCT pathkeys have been marked as redundant due to constants
existing in all of the EquivalenceClasses of the DISTINCT columns,
then it looks like it should be okay not to bother using a Unique node
to remove duplicate results.
When all the distinct pathkeys are redundant then there can only be,
at most, 1 single distinct value. There may be many rows with that
value, but we can remove those extra ones with a LIMIT 1 rather than
troubling over needlessly uniquifing them.
This might not be a hugely common case, but; 1) it is very cheap to
detect and 2) the speedups are likely to be *very* good.
With the attached we get:
regression=# explain (analyze, costs off, timing off) SELECT DISTINCT
four,1,2,3 FROM tenk1 WHERE four = 0;
QUERY PLAN
-------------------------------------------------
Limit (actual rows=1 loops=1)
-> Seq Scan on tenk1 (actual rows=1 loops=1)
Filter: (four = 0)
Planning Time: 0.215 ms
Execution Time: 0.071 ms
naturally, if we removed the WHERE four = 0, we can't optimise this
plan using this method.
I see no reason why this also can't work for DISTINCT ON too.
regression=# explain (analyze, costs off, timing off) SELECT DISTINCT
ON (four,two) four,two FROM tenk1 WHERE four = 0 order by 1,2;
QUERY PLAN
----------------------------------------------------------
Unique (actual rows=1 loops=1)
-> Sort (actual rows=2500 loops=1)
Sort Key: two
Sort Method: quicksort Memory: 175kB
-> Seq Scan on tenk1 (actual rows=2500 loops=1)
Filter: (four = 0)
Rows Removed by Filter: 7500
Planning Time: 0.123 ms
Execution Time: 4.251 ms
(9 rows)
then, of course, if we introduce some column that the pathkey is not
redundant for then we must do the distinct operation as normal.
regression=# explain (analyze, costs off, timing off) SELECT DISTINCT
four,two FROM tenk1 WHERE four = 0 order by 1,2;
QUERY PLAN
----------------------------------------------------------
Sort (actual rows=1 loops=1)
Sort Key: two
Sort Method: quicksort Memory: 25kB
-> HashAggregate (actual rows=1 loops=1)
Group Key: four, two
Batches: 1 Memory Usage: 24kB
-> Seq Scan on tenk1 (actual rows=2500 loops=1)
Filter: (four = 0)
Rows Removed by Filter: 7500
Planning Time: 0.137 ms
Execution Time: 4.274 ms
(11 rows)
Does this seem like something we'd want to do?
Patch attached.
David
[1] https://postgr.es/m/MEYPR01MB7101CD5DA0A07C9DE2B74850A4239@MEYPR01MB7101.ausprd01.prod.outlook.com
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5d0fd6e072..84856721f3 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4764,8 +4764,6 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
* the other.)
*/
List *needed_pathkeys;
- Path *path;
- ListCell *lc;
if (parse->hasDistinctOn &&
list_length(root->distinct_pathkeys) <
@@ -4774,44 +4772,73 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
else
needed_pathkeys = root->distinct_pathkeys;
- foreach(lc, input_rel->pathlist)
+ /*
+ * needed_pathkeys may have become empty if all of the pathkeys were
+ * determined to be redundant. If all of the pathkeys are redundant
+ * then each DISTINCT target must only allow a single value, therefore
+ * all resulting tuples must be identical. We can uniquify these
+ * tuples simply by just taking the first tuple. All we do here is
+ * add a path to do LIMIT 1 on the cheapest input path.
+ *
+ * XXX we could end up with 2 Limit nodes if the query already has a
+ * LIMIT clause. Does that matter?
+ */
+ if (needed_pathkeys == NIL)
+ {
+ Node *limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel,
+ cheapest_input_path, NULL, limitCount,
+ LIMIT_OPTION_COUNT, 0, 1));
+ }
+ else
{
- path = (Path *) lfirst(lc);
+ Path *path;
+ ListCell *lc;
- if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
+ foreach(lc, input_rel->pathlist)
{
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ path = (Path *) lfirst(lc);
+
+ if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
- }
- /* For explicit-sort case, always use the more rigorous clause */
- if (list_length(root->distinct_pathkeys) <
- list_length(root->sort_pathkeys))
- {
- needed_pathkeys = root->sort_pathkeys;
- /* Assert checks that parser didn't mess up... */
- Assert(pathkeys_contained_in(root->distinct_pathkeys,
- needed_pathkeys));
- }
- else
- needed_pathkeys = root->distinct_pathkeys;
+ /* For explicit-sort case, always use the more rigorous clause */
+ if (list_length(root->distinct_pathkeys) <
+ list_length(root->sort_pathkeys))
+ {
+ needed_pathkeys = root->sort_pathkeys;
+ /* Assert checks that parser didn't mess up... */
+ Assert(pathkeys_contained_in(root->distinct_pathkeys,
+ needed_pathkeys));
+ }
+ else
+ needed_pathkeys = root->distinct_pathkeys;
- path = cheapest_input_path;
- if (!pathkeys_contained_in(needed_pathkeys, path->pathkeys))
- path = (Path *) create_sort_path(root, distinct_rel,
- path,
- needed_pathkeys,
- -1.0);
+ path = cheapest_input_path;
+ if (!pathkeys_contained_in(needed_pathkeys, path->pathkeys))
+ path = (Path *) create_sort_path(root, distinct_rel,
+ path,
+ needed_pathkeys,
+ -1.0);
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
/*
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 748419cee0..6ce889d87c 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -279,6 +279,60 @@ RESET max_parallel_workers_per_gather;
RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ four
+------
+ 0
+(1 row)
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ QUERY PLAN
+---------------------------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: ((two <> 0) AND (four = 0))
+(3 rows)
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ four
+------
+(0 rows)
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ four | ?column? | ?column? | ?column?
+------+----------+----------+----------
+ 0 | 1 | 2 | 3
+(1 row)
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/expected/select_distinct_on.out b/src/test/regress/expected/select_distinct_on.out
index 3d98990991..2e38f14adb 100644
--- a/src/test/regress/expected/select_distinct_on.out
+++ b/src/test/regress/expected/select_distinct_on.out
@@ -73,3 +73,27 @@ select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
0 | -2147483647
(1 row)
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
+ QUERY PLAN
+--------------------------------------------------
+ Result
+ -> Limit
+ -> Seq Scan on tenk1
+ Filter: ((four = 0) AND (two = 0))
+(4 rows)
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
+ four | two
+------+-----
+ 0 | 0
+(1 row)
+
diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql
index f27ff714f8..34020adad1 100644
--- a/src/test/regress/sql/select_distinct.sql
+++ b/src/test/regress/sql/select_distinct.sql
@@ -146,6 +146,32 @@ RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/sql/select_distinct_on.sql b/src/test/regress/sql/select_distinct_on.sql
index 0920bd64b9..d5d6de1815 100644
--- a/src/test/regress/sql/select_distinct_on.sql
+++ b/src/test/regress/sql/select_distinct_on.sql
@@ -17,3 +17,17 @@ SELECT DISTINCT ON (string4, ten) string4, ten, two
-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses
select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
+
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
Attachments:
[text/plain] v1-use-limit-instead-of-unique-for-distinct.patch (9.1K, ../../CAApHDvqS0j8RUWRUSgCAXxOqnYjHUXmKwspRj4GzVfOO25ByHA@mail.gmail.com/2-v1-use-limit-instead-of-unique-for-distinct.patch)
download | inline diff:
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5d0fd6e072..84856721f3 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4764,8 +4764,6 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
* the other.)
*/
List *needed_pathkeys;
- Path *path;
- ListCell *lc;
if (parse->hasDistinctOn &&
list_length(root->distinct_pathkeys) <
@@ -4774,44 +4772,73 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
else
needed_pathkeys = root->distinct_pathkeys;
- foreach(lc, input_rel->pathlist)
+ /*
+ * needed_pathkeys may have become empty if all of the pathkeys were
+ * determined to be redundant. If all of the pathkeys are redundant
+ * then each DISTINCT target must only allow a single value, therefore
+ * all resulting tuples must be identical. We can uniquify these
+ * tuples simply by just taking the first tuple. All we do here is
+ * add a path to do LIMIT 1 on the cheapest input path.
+ *
+ * XXX we could end up with 2 Limit nodes if the query already has a
+ * LIMIT clause. Does that matter?
+ */
+ if (needed_pathkeys == NIL)
+ {
+ Node *limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel,
+ cheapest_input_path, NULL, limitCount,
+ LIMIT_OPTION_COUNT, 0, 1));
+ }
+ else
{
- path = (Path *) lfirst(lc);
+ Path *path;
+ ListCell *lc;
- if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
+ foreach(lc, input_rel->pathlist)
{
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ path = (Path *) lfirst(lc);
+
+ if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
- }
- /* For explicit-sort case, always use the more rigorous clause */
- if (list_length(root->distinct_pathkeys) <
- list_length(root->sort_pathkeys))
- {
- needed_pathkeys = root->sort_pathkeys;
- /* Assert checks that parser didn't mess up... */
- Assert(pathkeys_contained_in(root->distinct_pathkeys,
- needed_pathkeys));
- }
- else
- needed_pathkeys = root->distinct_pathkeys;
+ /* For explicit-sort case, always use the more rigorous clause */
+ if (list_length(root->distinct_pathkeys) <
+ list_length(root->sort_pathkeys))
+ {
+ needed_pathkeys = root->sort_pathkeys;
+ /* Assert checks that parser didn't mess up... */
+ Assert(pathkeys_contained_in(root->distinct_pathkeys,
+ needed_pathkeys));
+ }
+ else
+ needed_pathkeys = root->distinct_pathkeys;
- path = cheapest_input_path;
- if (!pathkeys_contained_in(needed_pathkeys, path->pathkeys))
- path = (Path *) create_sort_path(root, distinct_rel,
- path,
- needed_pathkeys,
- -1.0);
+ path = cheapest_input_path;
+ if (!pathkeys_contained_in(needed_pathkeys, path->pathkeys))
+ path = (Path *) create_sort_path(root, distinct_rel,
+ path,
+ needed_pathkeys,
+ -1.0);
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
/*
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 748419cee0..6ce889d87c 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -279,6 +279,60 @@ RESET max_parallel_workers_per_gather;
RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ four
+------
+ 0
+(1 row)
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ QUERY PLAN
+---------------------------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: ((two <> 0) AND (four = 0))
+(3 rows)
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ four
+------
+(0 rows)
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ four | ?column? | ?column? | ?column?
+------+----------+----------+----------
+ 0 | 1 | 2 | 3
+(1 row)
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/expected/select_distinct_on.out b/src/test/regress/expected/select_distinct_on.out
index 3d98990991..2e38f14adb 100644
--- a/src/test/regress/expected/select_distinct_on.out
+++ b/src/test/regress/expected/select_distinct_on.out
@@ -73,3 +73,27 @@ select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
0 | -2147483647
(1 row)
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
+ QUERY PLAN
+--------------------------------------------------
+ Result
+ -> Limit
+ -> Seq Scan on tenk1
+ Filter: ((four = 0) AND (two = 0))
+(4 rows)
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
+ four | two
+------+-----
+ 0 | 0
+(1 row)
+
diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql
index f27ff714f8..34020adad1 100644
--- a/src/test/regress/sql/select_distinct.sql
+++ b/src/test/regress/sql/select_distinct.sql
@@ -146,6 +146,32 @@ RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/sql/select_distinct_on.sql b/src/test/regress/sql/select_distinct_on.sql
index 0920bd64b9..d5d6de1815 100644
--- a/src/test/regress/sql/select_distinct_on.sql
+++ b/src/test/regress/sql/select_distinct_on.sql
@@ -17,3 +17,17 @@ SELECT DISTINCT ON (string4, ten) string4, ten, two
-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses
select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
+
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 AND two = 0 ORDER BY 1,2;
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-12 11:29 Richard Guo <[email protected]>
parent: David Rowley <[email protected]>
1 sibling, 1 reply; 36+ messages in thread
From: Richard Guo @ 2022-10-12 11:29 UTC (permalink / raw)
To: David Rowley <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Wed, Oct 12, 2022 at 5:19 PM David Rowley <[email protected]> wrote:
> When all the distinct pathkeys are redundant then there can only be,
> at most, 1 single distinct value. There may be many rows with that
> value, but we can remove those extra ones with a LIMIT 1 rather than
> troubling over needlessly uniquifing them.
I'm not sure if this case is common enough in practice, but since this
patch is very straightforward and adds no more costs, I think it's worth
doing.
I also have concerns about the 2 Limit nodes pointed by the comment
inside the patch. Maybe we can check with limit_needed() and manually
add the limit node only if there is no LIMIT clause in the origin query?
Thanks
Richard
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-12 12:13 Richard Guo <[email protected]>
parent: David Rowley <[email protected]>
1 sibling, 1 reply; 36+ messages in thread
From: Richard Guo @ 2022-10-12 12:13 UTC (permalink / raw)
To: David Rowley <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Wed, Oct 12, 2022 at 5:19 PM David Rowley <[email protected]> wrote:
> When all the distinct pathkeys are redundant then there can only be,
> at most, 1 single distinct value. There may be many rows with that
> value, but we can remove those extra ones with a LIMIT 1 rather than
> troubling over needlessly uniquifing them.
>
> This might not be a hugely common case, but; 1) it is very cheap to
> detect and 2) the speedups are likely to be *very* good.
>
> With the attached we get:
>
> regression=# explain (analyze, costs off, timing off) SELECT DISTINCT
> four,1,2,3 FROM tenk1 WHERE four = 0;
> QUERY PLAN
> -------------------------------------------------
> Limit (actual rows=1 loops=1)
> -> Seq Scan on tenk1 (actual rows=1 loops=1)
> Filter: (four = 0)
> Planning Time: 0.215 ms
> Execution Time: 0.071 ms
>
> naturally, if we removed the WHERE four = 0, we can't optimise this
> plan using this method.
>
> I see no reason why this also can't work for DISTINCT ON too.
For DISTINCT ON, if all the distinct pathkeys are redundant but there
are available sort pathkeys, then for adequately-presorted paths I think
we can also apply this optimization, using a Limit 1 rather than Unique.
regression=# explain (analyze, costs off, timing off) select distinct on
(four) * from tenk1 where four = 0 order by four, hundred desc;
QUERY PLAN
--------------------------------------------------------------------------------
Limit (actual rows=1 loops=1)
-> Index Scan Backward using tenk1_hundred on tenk1 (actual rows=1
loops=1)
Filter: (four = 0)
Rows Removed by Filter: 300
Planning Time: 0.165 ms
Execution Time: 0.458 ms
(6 rows)
Thanks
Richard
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-12 20:41 David Rowley <[email protected]>
parent: Richard Guo <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: David Rowley @ 2022-10-12 20:41 UTC (permalink / raw)
To: Richard Guo <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, 13 Oct 2022 at 00:30, Richard Guo <[email protected]> wrote:
> I also have concerns about the 2 Limit nodes pointed by the comment
> inside the patch. Maybe we can check with limit_needed() and manually
> add the limit node only if there is no LIMIT clause in the origin query?
I wasn't hugely concerned about this. I think we're a little limited
to what we can actually do about it too.
It seems easy enough to skip adding the LimitPath in
create_final_distinct_paths() if the existing query already has
exactly LIMIT 1. However, if they've written LIMIT 10 or LIMIT
random()*1234 then we must add the LimitPath to ensure we only get 1
row rather than 10 or some random number.
As for getting rid of the LIMIT 10 / LIMIT random()*1234, we store the
LIMIT clause information in the parse and currently that's what the
planner uses when creating the LimitPath for the LIMIT clause. I'd
quite like to avoid making any adjustments to the parse fields here.
(There's a general project desire to move away from the planner
modifying the parse. If we didn't do that we could do things like
re-plan queries with stronger optimization levels when they come out
too costly.)
We could do something like set some bool flag in PlannerInfo to tell
the planner not to bother adding the final LimitPath as we've already
added another which does the job, but is it really worth adding that
complexity for this patch? You already mentioned that "this patch is
very straightforward". I don't think it would be if we added code to
avoid the LimitPath duplication.
David
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-12 20:50 David Rowley <[email protected]>
parent: Richard Guo <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: David Rowley @ 2022-10-12 20:50 UTC (permalink / raw)
To: Richard Guo <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, 13 Oct 2022 at 01:13, Richard Guo <[email protected]> wrote:
> For DISTINCT ON, if all the distinct pathkeys are redundant but there
> are available sort pathkeys, then for adequately-presorted paths I think
> we can also apply this optimization, using a Limit 1 rather than Unique.
>
> regression=# explain (analyze, costs off, timing off) select distinct on (four) * from tenk1 where four = 0 order by four, hundred desc;
> QUERY PLAN
> --------------------------------------------------------------------------------
> Limit (actual rows=1 loops=1)
> -> Index Scan Backward using tenk1_hundred on tenk1 (actual rows=1 loops=1)
> Filter: (four = 0)
> Rows Removed by Filter: 300
I don't think we can optimise this case, at least not the same way I'm
doing it in the patch I attached.
The problem is that I'm only added the LimitPath to the
cheapest_total_path. I think to make your case work we'd need to add
the LimitPath only in cases where the distinct_pathkeys are empty but
the sort_pathkeys are not and hasDistinctOn is true and the path has
pathkeys_contained_in(root->sort_pathkeys, path->pathkeys). I think
that's doable, but it's become quite a bit more complex than the patch
I proposed. Maybe it's worth a 2nd effort for that part?
David
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-13 03:39 Richard Guo <[email protected]>
parent: David Rowley <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Richard Guo @ 2022-10-13 03:39 UTC (permalink / raw)
To: David Rowley <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, Oct 13, 2022 at 4:41 AM David Rowley <[email protected]> wrote:
> We could do something like set some bool flag in PlannerInfo to tell
> the planner not to bother adding the final LimitPath as we've already
> added another which does the job, but is it really worth adding that
> complexity for this patch? You already mentioned that "this patch is
> very straightforward". I don't think it would be if we added code to
> avoid the LimitPath duplication.
Yeah, maybe this is the right way to do it. I agree that this would
complicate the code. Not sure if it's worth doing.
Thanks
Richard
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-13 03:47 Richard Guo <[email protected]>
parent: David Rowley <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: Richard Guo @ 2022-10-13 03:47 UTC (permalink / raw)
To: David Rowley <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, Oct 13, 2022 at 4:50 AM David Rowley <[email protected]> wrote:
> The problem is that I'm only added the LimitPath to the
> cheapest_total_path. I think to make your case work we'd need to add
> the LimitPath only in cases where the distinct_pathkeys are empty but
> the sort_pathkeys are not and hasDistinctOn is true and the path has
> pathkeys_contained_in(root->sort_pathkeys, path->pathkeys). I think
> that's doable, but it's become quite a bit more complex than the patch
> I proposed. Maybe it's worth a 2nd effort for that part?
Currently in the patch the optimization is done before we check for
presorted paths or do the explicit sort of the cheapest path. How about
we move this optimization into the branch where we've found any
presorted paths? Maybe something like:
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4780,11 +4780,24 @@ create_final_distinct_paths(PlannerInfo *root,
RelOptInfo *input_rel,
if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
{
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
-
list_length(root->distinct_pathkeys),
- numDistinctRows));
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount = (Node *) makeConst(INT8OID, -1,
InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1),
false,
+ FLOAT8PASSBYVAL);
+
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel,
+ path, NULL, limitCount,
+ LIMIT_OPTION_COUNT, 0, 1));
+ }
+ else
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+
list_length(root->distinct_pathkeys),
+ numDistinctRows));
This again makes the code less 'straightforward', just to cover a more
uncommon case. I'm also not sure if it's worth doing.
Thanks
Richard
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-13 06:48 David Rowley <[email protected]>
parent: Richard Guo <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: David Rowley @ 2022-10-13 06:48 UTC (permalink / raw)
To: Richard Guo <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, 13 Oct 2022 at 16:47, Richard Guo <[email protected]> wrote:
> Currently in the patch the optimization is done before we check for
> presorted paths or do the explicit sort of the cheapest path. How about
> we move this optimization into the branch where we've found any
> presorted paths? Maybe something like:
I've attached a patch to that effect, but it turns out a bit more
complex than what you imagined. We still need to handle the case for
when there's no path that has the required pathkeys and we must add a
SortPath to the cheapest path. That requires adding some similar code
to add the LimitPath after the foreach loop over the pathlist is over.
I was also getting some weird plans like:
regression=# explain select distinct on (four) four,hundred from tenk1
where four=0 order by 1,2;
QUERY PLAN
----------------------------------------------------------------------
Sort (cost=0.20..0.20 rows=1 width=8)
Sort Key: hundred
-> Limit (cost=0.00..0.19 rows=1 width=8)
-> Seq Scan on tenk1 (cost=0.00..470.00 rows=2500 width=8)
Filter: (four = 0)
To stop the planner from adding that final sort, I opted to hack the
LimitPath's pathkeys to say that it's already sorted by the
PlannerInfo's sort_pathkeys. That feels slightly icky, but it does
seem a little wasteful to initialise a sort node on every execution of
the plan to sort a single tuple.
David
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5d0fd6e072..5c4e4dc5cd 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4780,11 +4780,53 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
{
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * distinct_pathkeys may have become empty if all of the
+ * pathkeys were determined to be redundant. If all of the
+ * pathkeys are redundant then each DISTINCT target must only
+ * allow a single value, therefore all resulting tuples must
+ * be identical. We can uniquify these tuples simply by just
+ * taking the first tuple. All we do here is add a path to do
+ * LIMIT 1 on path. When doing DISTINCT ON we may still have
+ * a non-NIL sort_pathkeys list, so we must still only do this
+ * with paths which are contained in needed_pathkeys.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount;
+ LimitPath *lpath;
+
+ limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ /*
+ * If the query already has a LIMIT clause, then we could
+ * end up with a duplicate LimitPath in the final plan.
+ * That does not seem worth troubling over too much.
+ */
+ lpath = create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT,
+ 0, 1);
+
+ /*
+ * We set the LimitPath's pathkeys to the sort_pathkeys
+ * since there can only be a single row after the LIMIT to
+ * save the planner adding a useless SortPath for the
+ * ORDER BY.
+ */
+ lpath->path.pathkeys = root->sort_pathkeys;
+ add_path(distinct_rel, (Path *) lpath);
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
}
@@ -4805,13 +4847,33 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
path = (Path *) create_sort_path(root, distinct_rel,
path,
needed_pathkeys,
- -1.0);
+ root->distinct_pathkeys == NIL ?
+ 1.0 : -1.0);
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * As above, use a LimitPath instead of a UniquePath when all of the
+ * distinct_pathkeys are redundant and we're only going to get a
+ * series of tuples all with the same values anyway.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT, 0, 1));
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
/*
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 748419cee0..6ce889d87c 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -279,6 +279,60 @@ RESET max_parallel_workers_per_gather;
RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ four
+------
+ 0
+(1 row)
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ QUERY PLAN
+---------------------------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: ((two <> 0) AND (four = 0))
+(3 rows)
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ four
+------
+(0 rows)
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ four | ?column? | ?column? | ?column?
+------+----------+----------+----------
+ 0 | 1 | 2 | 3
+(1 row)
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/expected/select_distinct_on.out b/src/test/regress/expected/select_distinct_on.out
index 3d98990991..b2978c1114 100644
--- a/src/test/regress/expected/select_distinct_on.out
+++ b/src/test/regress/expected/select_distinct_on.out
@@ -73,3 +73,53 @@ select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
0 | -2147483647
(1 row)
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ QUERY PLAN
+----------------------------------
+ Result
+ -> Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(4 rows)
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ four | two
+------+-----
+ 0 | 0
+(1 row)
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+----------------------------------
+ Limit
+ -> Sort
+ Sort Key: two
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(5 rows)
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+-----------------------------------------------------
+ Result
+ -> Limit
+ -> Index Scan using tenk1_hundred on tenk1
+ Filter: (four = 0)
+(4 rows)
+
diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql
index f27ff714f8..34020adad1 100644
--- a/src/test/regress/sql/select_distinct.sql
+++ b/src/test/regress/sql/select_distinct.sql
@@ -146,6 +146,32 @@ RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/sql/select_distinct_on.sql b/src/test/regress/sql/select_distinct_on.sql
index 0920bd64b9..261e6140fe 100644
--- a/src/test/regress/sql/select_distinct_on.sql
+++ b/src/test/regress/sql/select_distinct_on.sql
@@ -17,3 +17,28 @@ SELECT DISTINCT ON (string4, ten) string4, ten, two
-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses
select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
+
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
Attachments:
[text/plain] v2-use-limit-instead-of-unique-for-distinct.patch (9.8K, ../../CAApHDvqJJWQeWycoF9k0jSoQ=_Q-a55d7XoviP0o3dxjGKsoiA@mail.gmail.com/2-v2-use-limit-instead-of-unique-for-distinct.patch)
download | inline diff:
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5d0fd6e072..5c4e4dc5cd 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4780,11 +4780,53 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
{
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * distinct_pathkeys may have become empty if all of the
+ * pathkeys were determined to be redundant. If all of the
+ * pathkeys are redundant then each DISTINCT target must only
+ * allow a single value, therefore all resulting tuples must
+ * be identical. We can uniquify these tuples simply by just
+ * taking the first tuple. All we do here is add a path to do
+ * LIMIT 1 on path. When doing DISTINCT ON we may still have
+ * a non-NIL sort_pathkeys list, so we must still only do this
+ * with paths which are contained in needed_pathkeys.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount;
+ LimitPath *lpath;
+
+ limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ /*
+ * If the query already has a LIMIT clause, then we could
+ * end up with a duplicate LimitPath in the final plan.
+ * That does not seem worth troubling over too much.
+ */
+ lpath = create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT,
+ 0, 1);
+
+ /*
+ * We set the LimitPath's pathkeys to the sort_pathkeys
+ * since there can only be a single row after the LIMIT to
+ * save the planner adding a useless SortPath for the
+ * ORDER BY.
+ */
+ lpath->path.pathkeys = root->sort_pathkeys;
+ add_path(distinct_rel, (Path *) lpath);
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
}
@@ -4805,13 +4847,33 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
path = (Path *) create_sort_path(root, distinct_rel,
path,
needed_pathkeys,
- -1.0);
+ root->distinct_pathkeys == NIL ?
+ 1.0 : -1.0);
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * As above, use a LimitPath instead of a UniquePath when all of the
+ * distinct_pathkeys are redundant and we're only going to get a
+ * series of tuples all with the same values anyway.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT, 0, 1));
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
/*
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 748419cee0..6ce889d87c 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -279,6 +279,60 @@ RESET max_parallel_workers_per_gather;
RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ four
+------
+ 0
+(1 row)
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ QUERY PLAN
+---------------------------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: ((two <> 0) AND (four = 0))
+(3 rows)
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ four
+------
+(0 rows)
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ four | ?column? | ?column? | ?column?
+------+----------+----------+----------
+ 0 | 1 | 2 | 3
+(1 row)
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/expected/select_distinct_on.out b/src/test/regress/expected/select_distinct_on.out
index 3d98990991..b2978c1114 100644
--- a/src/test/regress/expected/select_distinct_on.out
+++ b/src/test/regress/expected/select_distinct_on.out
@@ -73,3 +73,53 @@ select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
0 | -2147483647
(1 row)
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ QUERY PLAN
+----------------------------------
+ Result
+ -> Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(4 rows)
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ four | two
+------+-----
+ 0 | 0
+(1 row)
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+----------------------------------
+ Limit
+ -> Sort
+ Sort Key: two
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(5 rows)
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+-----------------------------------------------------
+ Result
+ -> Limit
+ -> Index Scan using tenk1_hundred on tenk1
+ Filter: (four = 0)
+(4 rows)
+
diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql
index f27ff714f8..34020adad1 100644
--- a/src/test/regress/sql/select_distinct.sql
+++ b/src/test/regress/sql/select_distinct.sql
@@ -146,6 +146,32 @@ RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/sql/select_distinct_on.sql b/src/test/regress/sql/select_distinct_on.sql
index 0920bd64b9..261e6140fe 100644
--- a/src/test/regress/sql/select_distinct_on.sql
+++ b/src/test/regress/sql/select_distinct_on.sql
@@ -17,3 +17,28 @@ SELECT DISTINCT ON (string4, ten) string4, ten, two
-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses
select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
+
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-13 08:17 Richard Guo <[email protected]>
parent: David Rowley <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: Richard Guo @ 2022-10-13 08:17 UTC (permalink / raw)
To: David Rowley <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, Oct 13, 2022 at 2:48 PM David Rowley <[email protected]> wrote:
> On Thu, 13 Oct 2022 at 16:47, Richard Guo <[email protected]> wrote:
> > Currently in the patch the optimization is done before we check for
> > presorted paths or do the explicit sort of the cheapest path. How about
> > we move this optimization into the branch where we've found any
> > presorted paths? Maybe something like:
>
> I've attached a patch to that effect, but it turns out a bit more
> complex than what you imagined. We still need to handle the case for
> when there's no path that has the required pathkeys and we must add a
> SortPath to the cheapest path. That requires adding some similar code
> to add the LimitPath after the foreach loop over the pathlist is over.
Thanks for the new patch. Previously I considered we just apply this
optimization for adequately-presorted paths so that we can just fetch
the first row from that path. But yes we can also do this optimization
for explicit-sort case so that we can get the result from a top-1
heapsort, just like the new patch does.
I was also getting some weird plans like:
>
> regression=# explain select distinct on (four) four,hundred from tenk1
> where four=0 order by 1,2;
> QUERY PLAN
> ----------------------------------------------------------------------
> Sort (cost=0.20..0.20 rows=1 width=8)
> Sort Key: hundred
> -> Limit (cost=0.00..0.19 rows=1 width=8)
> -> Seq Scan on tenk1 (cost=0.00..470.00 rows=2500 width=8)
> Filter: (four = 0)
>
> To stop the planner from adding that final sort, I opted to hack the
> LimitPath's pathkeys to say that it's already sorted by the
> PlannerInfo's sort_pathkeys. That feels slightly icky, but it does
> seem a little wasteful to initialise a sort node on every execution of
> the plan to sort a single tuple.
I don't get how this plan comes out. It seems not correct because Limit
node above an unsorted path would give us an unpredictable row. I tried
this query without the hack to LimitPath's pathkeys and I get plans
below, with or with index scan:
explain (costs off) select distinct on (four) four,hundred from tenk1
where four=0 order by 1,2;
QUERY PLAN
-----------------------------------------------------
Result
-> Limit
-> Index Scan using tenk1_hundred on tenk1
Filter: (four = 0)
explain (costs off) select distinct on (four) four,hundred from tenk1
where four=0 order by 1,2;
QUERY PLAN
----------------------------------
Limit
-> Sort
Sort Key: hundred
-> Seq Scan on tenk1
Filter: (four = 0)
Thanks
Richard
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-13 10:43 David Rowley <[email protected]>
parent: Richard Guo <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: David Rowley @ 2022-10-13 10:43 UTC (permalink / raw)
To: Richard Guo <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, 13 Oct 2022 at 21:17, Richard Guo <[email protected]> wrote:
>
> On Thu, Oct 13, 2022 at 2:48 PM David Rowley <[email protected]> wrote:
>> To stop the planner from adding that final sort, I opted to hack the
>> LimitPath's pathkeys to say that it's already sorted by the
>> PlannerInfo's sort_pathkeys. That feels slightly icky, but it does
>> seem a little wasteful to initialise a sort node on every execution of
>> the plan to sort a single tuple.
>
>
> I don't get how this plan comes out. It seems not correct because Limit
> node above an unsorted path would give us an unpredictable row.
Actually, you're right. That manual setting of the pathkeys is an
unneeded remanent from a bug I fixed before sending out v2. It can
just be removed.
I've attached the v3 patch.
David
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5d0fd6e072..839b034b29 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4780,11 +4780,44 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
{
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * distinct_pathkeys may have become empty if all of the
+ * pathkeys were determined to be redundant. If all of the
+ * pathkeys are redundant then each DISTINCT target must only
+ * allow a single value, therefore all resulting tuples must
+ * be identical. We can uniquify these tuples simply by just
+ * taking the first tuple. All we do here is add a path to do
+ * LIMIT 1 on path. When doing DISTINCT ON we may still have
+ * a non-NIL sort_pathkeys list, so we must still only do this
+ * with paths which are contained in needed_pathkeys.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount;
+
+ limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ /*
+ * If the query already has a LIMIT clause, then we could
+ * end up with a duplicate LimitPath in the final plan.
+ * That does not seem worth troubling over too much.
+ */
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT,
+ 0, 1));
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
}
@@ -4805,13 +4838,33 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
path = (Path *) create_sort_path(root, distinct_rel,
path,
needed_pathkeys,
- -1.0);
+ root->distinct_pathkeys == NIL ?
+ 1.0 : -1.0);
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * As above, use a LimitPath instead of a UniquePath when all of the
+ * distinct_pathkeys are redundant and we're only going to get a
+ * series of tuples all with the same values anyway.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT, 0, 1));
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
/*
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 748419cee0..6ce889d87c 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -279,6 +279,60 @@ RESET max_parallel_workers_per_gather;
RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ four
+------
+ 0
+(1 row)
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ QUERY PLAN
+---------------------------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: ((two <> 0) AND (four = 0))
+(3 rows)
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ four
+------
+(0 rows)
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ four | ?column? | ?column? | ?column?
+------+----------+----------+----------
+ 0 | 1 | 2 | 3
+(1 row)
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/expected/select_distinct_on.out b/src/test/regress/expected/select_distinct_on.out
index 3d98990991..b2978c1114 100644
--- a/src/test/regress/expected/select_distinct_on.out
+++ b/src/test/regress/expected/select_distinct_on.out
@@ -73,3 +73,53 @@ select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
0 | -2147483647
(1 row)
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ QUERY PLAN
+----------------------------------
+ Result
+ -> Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(4 rows)
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ four | two
+------+-----
+ 0 | 0
+(1 row)
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+----------------------------------
+ Limit
+ -> Sort
+ Sort Key: two
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(5 rows)
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+-----------------------------------------------------
+ Result
+ -> Limit
+ -> Index Scan using tenk1_hundred on tenk1
+ Filter: (four = 0)
+(4 rows)
+
diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql
index f27ff714f8..34020adad1 100644
--- a/src/test/regress/sql/select_distinct.sql
+++ b/src/test/regress/sql/select_distinct.sql
@@ -146,6 +146,32 @@ RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/sql/select_distinct_on.sql b/src/test/regress/sql/select_distinct_on.sql
index 0920bd64b9..261e6140fe 100644
--- a/src/test/regress/sql/select_distinct_on.sql
+++ b/src/test/regress/sql/select_distinct_on.sql
@@ -17,3 +17,28 @@ SELECT DISTINCT ON (string4, ten) string4, ten, two
-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses
select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
+
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
Attachments:
[text/plain] v3-use-limit-instead-of-unique-for-distinct.patch (9.5K, ../../CAApHDvp11sTNa--eexB1VF+BU31O9_SNwHkOPa8cxWog6pDcTA@mail.gmail.com/2-v3-use-limit-instead-of-unique-for-distinct.patch)
download | inline diff:
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5d0fd6e072..839b034b29 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4780,11 +4780,44 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
{
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * distinct_pathkeys may have become empty if all of the
+ * pathkeys were determined to be redundant. If all of the
+ * pathkeys are redundant then each DISTINCT target must only
+ * allow a single value, therefore all resulting tuples must
+ * be identical. We can uniquify these tuples simply by just
+ * taking the first tuple. All we do here is add a path to do
+ * LIMIT 1 on path. When doing DISTINCT ON we may still have
+ * a non-NIL sort_pathkeys list, so we must still only do this
+ * with paths which are contained in needed_pathkeys.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount;
+
+ limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ /*
+ * If the query already has a LIMIT clause, then we could
+ * end up with a duplicate LimitPath in the final plan.
+ * That does not seem worth troubling over too much.
+ */
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT,
+ 0, 1));
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
}
@@ -4805,13 +4838,33 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
path = (Path *) create_sort_path(root, distinct_rel,
path,
needed_pathkeys,
- -1.0);
+ root->distinct_pathkeys == NIL ?
+ 1.0 : -1.0);
- add_path(distinct_rel, (Path *)
- create_upper_unique_path(root, distinct_rel,
- path,
- list_length(root->distinct_pathkeys),
- numDistinctRows));
+ /*
+ * As above, use a LimitPath instead of a UniquePath when all of the
+ * distinct_pathkeys are redundant and we're only going to get a
+ * series of tuples all with the same values anyway.
+ */
+ if (root->distinct_pathkeys == NIL)
+ {
+ Node *limitCount = (Node *) makeConst(INT8OID, -1, InvalidOid,
+ sizeof(int64),
+ Int64GetDatum(1), false,
+ FLOAT8PASSBYVAL);
+
+ add_path(distinct_rel, (Path *)
+ create_limit_path(root, distinct_rel, path, NULL,
+ limitCount, LIMIT_OPTION_COUNT, 0, 1));
+ }
+ else
+ {
+ add_path(distinct_rel, (Path *)
+ create_upper_unique_path(root, distinct_rel,
+ path,
+ list_length(root->distinct_pathkeys),
+ numDistinctRows));
+ }
}
/*
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out
index 748419cee0..6ce889d87c 100644
--- a/src/test/regress/expected/select_distinct.out
+++ b/src/test/regress/expected/select_distinct.out
@@ -279,6 +279,60 @@ RESET max_parallel_workers_per_gather;
RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+ four
+------
+ 0
+(1 row)
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ QUERY PLAN
+---------------------------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: ((two <> 0) AND (four = 0))
+(3 rows)
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+ four
+------
+(0 rows)
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ QUERY PLAN
+----------------------------
+ Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(3 rows)
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+ four | ?column? | ?column? | ?column?
+------+----------+----------+----------
+ 0 | 1 | 2 | 3
+(1 row)
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/expected/select_distinct_on.out b/src/test/regress/expected/select_distinct_on.out
index 3d98990991..b2978c1114 100644
--- a/src/test/regress/expected/select_distinct_on.out
+++ b/src/test/regress/expected/select_distinct_on.out
@@ -73,3 +73,53 @@ select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
0 | -2147483647
(1 row)
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ QUERY PLAN
+----------------------------------
+ Result
+ -> Limit
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(4 rows)
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+ four | two
+------+-----
+ 0 | 0
+(1 row)
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+----------------------------------
+ Limit
+ -> Sort
+ Sort Key: two
+ -> Seq Scan on tenk1
+ Filter: (four = 0)
+(5 rows)
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+ QUERY PLAN
+-----------------------------------------------------
+ Result
+ -> Limit
+ -> Index Scan using tenk1_hundred on tenk1
+ Filter: (four = 0)
+(4 rows)
+
diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql
index f27ff714f8..34020adad1 100644
--- a/src/test/regress/sql/select_distinct.sql
+++ b/src/test/regress/sql/select_distinct.sql
@@ -146,6 +146,32 @@ RESET min_parallel_table_scan_size;
RESET parallel_setup_cost;
RESET parallel_tuple_cost;
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure the above gives us the correct result
+SELECT DISTINCT four FROM tenk1 WHERE four = 0;
+
+-- Ensure we get a plan with a Limit 1
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure no rows are returned
+SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0;
+
+-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
+-- Ensure we only get 1 row
+SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0;
+
--
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
-- very own regression file.
diff --git a/src/test/regress/sql/select_distinct_on.sql b/src/test/regress/sql/select_distinct_on.sql
index 0920bd64b9..261e6140fe 100644
--- a/src/test/regress/sql/select_distinct_on.sql
+++ b/src/test/regress/sql/select_distinct_on.sql
@@ -17,3 +17,28 @@ SELECT DISTINCT ON (string4, ten) string4, ten, two
-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses
select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;
+
+--
+-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when
+-- all of the distinct_pathkeys have been marked as redundant
+--
+
+-- Ensure we also get a LIMIT plan with DISTINCT ON
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- and check the result of the above query is correct
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1;
+
+-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,two
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
+
+-- Same again but use a column that is indexed so that we get an index scan
+-- then a limit
+EXPLAIN (COSTS OFF)
+SELECT DISTINCT ON (four) four,hundred
+ FROM tenk1 WHERE four = 0 ORDER BY 1,2;
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-14 02:14 Richard Guo <[email protected]>
parent: David Rowley <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: Richard Guo @ 2022-10-14 02:14 UTC (permalink / raw)
To: David Rowley <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, Oct 13, 2022 at 6:43 PM David Rowley <[email protected]> wrote:
> On Thu, 13 Oct 2022 at 21:17, Richard Guo <[email protected]> wrote:
> >
> > On Thu, Oct 13, 2022 at 2:48 PM David Rowley <[email protected]>
> wrote:
> >> To stop the planner from adding that final sort, I opted to hack the
> >> LimitPath's pathkeys to say that it's already sorted by the
> >> PlannerInfo's sort_pathkeys. That feels slightly icky, but it does
> >> seem a little wasteful to initialise a sort node on every execution of
> >> the plan to sort a single tuple.
> >
> >
> > I don't get how this plan comes out. It seems not correct because Limit
> > node above an unsorted path would give us an unpredictable row.
>
> Actually, you're right. That manual setting of the pathkeys is an
> unneeded remanent from a bug I fixed before sending out v2. It can
> just be removed.
>
> I've attached the v3 patch.
The v3 patch looks good to me.
Thanks
Richard
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-26 08:25 David Rowley <[email protected]>
parent: Richard Guo <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: David Rowley @ 2022-10-26 08:25 UTC (permalink / raw)
To: Richard Guo <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Fri, 14 Oct 2022 at 15:15, Richard Guo <[email protected]> wrote:
> The v3 patch looks good to me.
Thank you for looking at that.
One other thought I had about the duplicate "Limit" node in the final
plan was that we could make the limit clause an Expr like
LEAST(<existing limit clause>, 1). That way we could ensure we get at
most 1 row, but perhaps less if the expression given in the LIMIT
clause evaluated to 0. This will still work correctly when the
existing limit evaluates to NULL. I'm still just not that keen on this
idea as it means still having to either edit the parse's limitCount or
store the limit details in a new field in PlannerInfo and use that
when making the final LimitPath. However, I'm still not sure doing
this is worth the extra complexity.
If nobody else has any thoughts on this or the patch in general, then
I plan to push it in the next few days.
David
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-27 02:50 Richard Guo <[email protected]>
parent: David Rowley <[email protected]>
0 siblings, 1 reply; 36+ messages in thread
From: Richard Guo @ 2022-10-27 02:50 UTC (permalink / raw)
To: David Rowley <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Wed, Oct 26, 2022 at 4:25 PM David Rowley <[email protected]> wrote:
> One other thought I had about the duplicate "Limit" node in the final
> plan was that we could make the limit clause an Expr like
> LEAST(<existing limit clause>, 1). That way we could ensure we get at
> most 1 row, but perhaps less if the expression given in the LIMIT
> clause evaluated to 0. This will still work correctly when the
> existing limit evaluates to NULL. I'm still just not that keen on this
> idea as it means still having to either edit the parse's limitCount or
> store the limit details in a new field in PlannerInfo and use that
> when making the final LimitPath. However, I'm still not sure doing
> this is worth the extra complexity.
I find the duplicate "Limit" node is not that concerning after I realize
it may appear in other queries, such as
explain (analyze, timing off, costs off)
select * from (select * from (select * from generate_series(1,100)i limit
10) limit 5) limit 1;
QUERY PLAN
------------------------------------------------------------------------------
Limit (actual rows=1 loops=1)
-> Limit (actual rows=1 loops=1)
-> Limit (actual rows=1 loops=1)
-> Function Scan on generate_series i (actual rows=1
loops=1)
Although the situation is different in that the Limit node is actually
atop SubqueryScan which is removed afterwards, but the final plan
appears as a Limit node atop another Limit node.
So I wonder maybe we can just live with it, or resolve it in a separate
patch.
Thanks
Richard
^ permalink raw reply [nested|flat] 36+ messages in thread
* Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
@ 2022-10-28 10:17 David Rowley <[email protected]>
parent: Richard Guo <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: David Rowley @ 2022-10-28 10:17 UTC (permalink / raw)
To: Richard Guo <[email protected]>; +Cc: PostgreSQL Developers <[email protected]>
On Thu, 27 Oct 2022 at 15:50, Richard Guo <[email protected]> wrote:
> I find the duplicate "Limit" node is not that concerning after I realize
> it may appear in other queries, such as
>
> explain (analyze, timing off, costs off)
> select * from (select * from (select * from generate_series(1,100)i limit 10) limit 5) limit 1;
Yeah, the additional limits certainly are not incorrect. We could
maybe do something better, there just does not seem to be much point.
Perhaps fixing things like this would be better done with the
UniqueKey stuff that Andy Fan and I were working on a while back.
With LIMIT 1 everything would become unique and there'd be no need to
add another LimitPath.
I've now pushed the patch after making a small adjustment to one of
the comments which mentions about rows being "indistinguishable by an
equality check". I was made to think of the '-0.0'::float8 vs +0.0
case again and thought I'd better mention it for this patch.
Thanks for reviewing the patch.
David
^ permalink raw reply [nested|flat] 36+ messages in thread
* [PATCH v2 4/7] Row pattern recognition patch (executor).
@ 2023-06-26 08:05 Tatsuo Ishii <[email protected]>
0 siblings, 0 replies; 36+ messages in thread
From: Tatsuo Ishii @ 2023-06-26 08:05 UTC (permalink / raw)
---
src/backend/executor/nodeWindowAgg.c | 225 +++++++++++++++++++-
src/backend/utils/adt/windowfuncs.c | 302 ++++++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 9 +
src/include/nodes/execnodes.h | 13 ++
src/include/windowapi.h | 9 +
5 files changed, 548 insertions(+), 10 deletions(-)
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 310ac23e3a..bef2bc62b2 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -48,6 +48,7 @@
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/datum.h"
+#include "utils/fmgroids.h"
#include "utils/expandeddatum.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
@@ -159,6 +160,14 @@ typedef struct WindowStatePerAggData
bool restart; /* need to restart this agg in this cycle? */
} WindowStatePerAggData;
+/*
+ * Map between Var attno in a target list and the parsed attno.
+ */
+typedef struct AttnoMap {
+ List *attno; /* att number in target list (list of AttNumber) */
+ List *attnosyn; /* parsed att number (list of AttNumber) */
+} AttnoMap;
+
static void initialize_windowaggregate(WindowAggState *winstate,
WindowStatePerFunc perfuncstate,
WindowStatePerAgg peraggstate);
@@ -195,9 +204,9 @@ static Datum GetAggInitVal(Datum textInitVal, Oid transtype);
static bool are_peers(WindowAggState *winstate, TupleTableSlot *slot1,
TupleTableSlot *slot2);
-static bool window_gettupleslot(WindowObject winobj, int64 pos,
- TupleTableSlot *slot);
+static void attno_map(Node *node, AttnoMap *map);
+static bool attno_map_walker(Node *node, void *context);
/*
* initialize_windowaggregate
@@ -2388,6 +2397,12 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
TupleDesc scanDesc;
ListCell *l;
+ TargetEntry *te;
+ Expr *expr;
+ Var *var;
+ int nargs;
+ AttnoMap attnomap;
+
/* check for unsupported flags */
Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
@@ -2483,6 +2498,16 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
winstate->temp_slot_2 = ExecInitExtraTupleSlot(estate, scanDesc,
&TTSOpsMinimalTuple);
+ winstate->prev_slot = ExecInitExtraTupleSlot(estate, scanDesc,
+ &TTSOpsMinimalTuple);
+
+ winstate->next_slot = ExecInitExtraTupleSlot(estate, scanDesc,
+ &TTSOpsMinimalTuple);
+
+ winstate->null_slot = ExecInitExtraTupleSlot(estate, scanDesc,
+ &TTSOpsMinimalTuple);
+ winstate->null_slot = ExecStoreAllNullTuple(winstate->null_slot);
+
/*
* create frame head and tail slots only if needed (must create slots in
* exactly the same cases that update_frameheadpos and update_frametailpos
@@ -2667,6 +2692,71 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
winstate->inRangeAsc = node->inRangeAsc;
winstate->inRangeNullsFirst = node->inRangeNullsFirst;
+ /* Set up SKIP TO type */
+ winstate->rpSkipTo = node->rpSkipTo;
+ /* Set up row pattern recognition PATTERN clause */
+ winstate->patternVariableList = node->patternVariable;
+ winstate->patternRegexpList = node->patternRegexp;
+
+ /* Set up row pattern recognition DEFINE clause */
+
+ /*
+ * Collect mapping between varattno and varattnosyn in the targetlist.
+ * XXX: For now we only check RPR's argument. Eventually we have to
+ * recurse the targetlist to find out all mappings in Var nodes.
+ */
+ attnomap.attno = NIL;
+ attnomap.attnosyn = NIL;
+
+ foreach (l, node->plan.targetlist)
+ {
+ te = lfirst(l);
+ if (IsA(te->expr, WindowFunc))
+ {
+ WindowFunc *func = (WindowFunc *)te->expr;
+ if (func->winfnoid != F_RPR)
+ continue;
+
+ /* sanity check */
+ nargs = list_length(func->args);
+ if (list_length(func->args) != 1)
+ elog(ERROR, "RPR must have 1 argument but function %d has %d args", func->winfnoid, nargs);
+
+ expr = (Expr *) lfirst(list_head(func->args));
+ if (!IsA(expr, Var))
+ elog(ERROR, "RPR's arg is not Var");
+
+ var = (Var *)expr;
+ elog(DEBUG1, "resname: %s varattno: %d varattnosyn: %d",
+ te->resname, var->varattno, var->varattnosyn);
+ attnomap.attno = lappend_int(attnomap.attno, var->varattno);
+ attnomap.attnosyn = lappend_int(attnomap.attnosyn, var->varattnosyn);
+ }
+ }
+
+ winstate->defineVariableList = NIL;
+ winstate->defineClauseList = NIL;
+ if (node->defineClause != NIL)
+ {
+ foreach(l, node->defineClause)
+ {
+ char *name;
+ ExprState *exps;
+
+ te = lfirst(l);
+ name = te->resname;
+ expr = te->expr;
+
+ elog(DEBUG1, "defineVariable name: %s", name);
+ winstate->defineVariableList = lappend(winstate->defineVariableList,
+ makeString(pstrdup(name)));
+ /* tweak expr so that it referes to outer slot */
+ attno_map((Node *)expr, &attnomap);
+ exps = ExecInitExpr(expr, (PlanState *) winstate);
+ winstate->defineClauseList = lappend(winstate->defineClauseList, exps);
+ }
+ }
+
winstate->all_first = true;
winstate->partition_spooled = false;
winstate->more_partitions = false;
@@ -2674,6 +2764,76 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
return winstate;
}
+/*
+ * Rewrite Var node's varattno to the varattno which is used in the target
+ * list using AttnoMap. We also rewrite varno so that it sees outer tuple
+ * (PREV) or inner tuple (NEXT).
+ */
+static void
+attno_map(Node *node, AttnoMap *map)
+{
+ (void) expression_tree_walker(node, attno_map_walker, (void *) map);
+}
+
+static bool
+attno_map_walker(Node *node, void *context)
+{
+ FuncExpr *func;
+ int nargs;
+ Expr *expr;
+ Var *var;
+ AttnoMap *attnomap;
+ ListCell *lc1, *lc2;
+
+ if (node == NULL)
+ return false;
+
+ attnomap = (AttnoMap *) context;
+
+ if (IsA(node, FuncExpr))
+ {
+ func = (FuncExpr *)node;
+
+ if (func->funcid == F_PREV || func->funcid == F_NEXT)
+ {
+ /* sanity check */
+ nargs = list_length(func->args);
+ if (list_length(func->args) != 1)
+ elog(ERROR, "PREV/NEXT must have 1 argument but function %d has %d args", func->funcid, nargs);
+
+ expr = (Expr *) lfirst(list_head(func->args));
+ if (!IsA(expr, Var))
+ elog(ERROR, "PREV/NEXT's arg is not Var"); /* XXX: is it possible that arg type is Const? */
+ var = (Var *)expr;
+
+ if (func->funcid == F_PREV)
+ var->varno = OUTER_VAR;
+ else
+ var->varno = INNER_VAR;
+ }
+ return expression_tree_walker(node, attno_map_walker, (void *) context);
+ }
+ else if (IsA(node, Var))
+ {
+ var = (Var *)node;
+
+ elog(DEBUG1, "original varno: %d varattno: %d", var->varno, var->varattno);
+
+ forboth(lc1, attnomap->attno, lc2, attnomap->attnosyn)
+ {
+ int attno = lfirst_int(lc1);
+ int attnosyn = lfirst_int(lc2);
+
+ if (var->varattno == attnosyn)
+ {
+ elog(DEBUG1, "loc: %d rewrite varattno from: %d to %d", var->location, attnosyn, attno);
+ var->varattno = attno;
+ }
+ }
+ }
+ return expression_tree_walker(node, attno_map_walker, (void *) context);
+}
+
/* -----------------
* ExecEndWindowAgg
* -----------------
@@ -2691,6 +2851,8 @@ ExecEndWindowAgg(WindowAggState *node)
ExecClearTuple(node->agg_row_slot);
ExecClearTuple(node->temp_slot_1);
ExecClearTuple(node->temp_slot_2);
+ ExecClearTuple(node->prev_slot);
+ ExecClearTuple(node->next_slot);
if (node->framehead_slot)
ExecClearTuple(node->framehead_slot);
if (node->frametail_slot)
@@ -2740,6 +2902,8 @@ ExecReScanWindowAgg(WindowAggState *node)
ExecClearTuple(node->agg_row_slot);
ExecClearTuple(node->temp_slot_1);
ExecClearTuple(node->temp_slot_2);
+ ExecClearTuple(node->prev_slot);
+ ExecClearTuple(node->next_slot);
if (node->framehead_slot)
ExecClearTuple(node->framehead_slot);
if (node->frametail_slot)
@@ -3080,7 +3244,7 @@ are_peers(WindowAggState *winstate, TupleTableSlot *slot1,
*
* Returns true if successful, false if no such row
*/
-static bool
+bool
window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
{
WindowAggState *winstate = winobj->winstate;
@@ -3420,14 +3584,53 @@ WinGetFuncArgInFrame(WindowObject winobj, int argno,
WindowAggState *winstate;
ExprContext *econtext;
TupleTableSlot *slot;
- int64 abs_pos;
- int64 mark_pos;
Assert(WindowObjectIsValid(winobj));
winstate = winobj->winstate;
econtext = winstate->ss.ps.ps_ExprContext;
slot = winstate->temp_slot_1;
+ if (WinGetSlotInFrame(winobj, slot,
+ relpos, seektype, set_mark,
+ isnull, isout) == 0)
+ {
+ econtext->ecxt_outertuple = slot;
+ return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
+ econtext, isnull);
+ }
+
+ if (isout)
+ *isout = true;
+ *isnull = true;
+ return (Datum) 0;
+}
+
+/*
+ * WinGetSlotInFrame
+ * slot: TupleTableSlot to store the result
+ * relpos: signed rowcount offset from the seek position
+ * seektype: WINDOW_SEEK_HEAD or WINDOW_SEEK_TAIL
+ * set_mark: If the row is found/in frame and set_mark is true, the mark is
+ * moved to the row as a side-effect.
+ * isnull: output argument, receives isnull status of result
+ * isout: output argument, set to indicate whether target row position
+ * is out of frame (can pass NULL if caller doesn't care about this)
+ *
+ * Returns 0 if we successfullt got the slot. false if out of frame.
+ * (also isout is set)
+ */
+int
+WinGetSlotInFrame(WindowObject winobj, TupleTableSlot *slot,
+ int relpos, int seektype, bool set_mark,
+ bool *isnull, bool *isout)
+{
+ WindowAggState *winstate;
+ int64 abs_pos;
+ int64 mark_pos;
+
+ Assert(WindowObjectIsValid(winobj));
+ winstate = winobj->winstate;
+
switch (seektype)
{
case WINDOW_SEEK_CURRENT:
@@ -3583,15 +3786,13 @@ WinGetFuncArgInFrame(WindowObject winobj, int argno,
*isout = false;
if (set_mark)
WinSetMarkPosition(winobj, mark_pos);
- econtext->ecxt_outertuple = slot;
- return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
- econtext, isnull);
+ return 0;
out_of_frame:
if (isout)
*isout = true;
*isnull = true;
- return (Datum) 0;
+ return -1;
}
/*
@@ -3622,3 +3823,9 @@ WinGetFuncArgCurrent(WindowObject winobj, int argno, bool *isnull)
return ExecEvalExpr((ExprState *) list_nth(winobj->argstates, argno),
econtext, isnull);
}
+
+WindowAggState *
+WinGetAggState(WindowObject winobj)
+{
+ return winobj->winstate;
+}
diff --git a/src/backend/utils/adt/windowfuncs.c b/src/backend/utils/adt/windowfuncs.c
index b87a624fb2..74ef11ce55 100644
--- a/src/backend/utils/adt/windowfuncs.c
+++ b/src/backend/utils/adt/windowfuncs.c
@@ -13,6 +13,9 @@
*/
#include "postgres.h"
+#include "catalog/pg_collation_d.h"
+#include "executor/executor.h"
+#include "nodes/execnodes.h"
#include "nodes/supportnodes.h"
#include "utils/builtins.h"
#include "windowapi.h"
@@ -36,10 +39,21 @@ typedef struct
int64 remainder; /* (total rows) % (bucket num) */
} ntile_context;
+/*
+ * rpr process information.
+ * Used for AFTER MATCH SKIP PAST LAST ROW
+ */
+typedef struct SkipContext
+{
+ int64 pos; /* last row absolute position */
+} SkipContext;
+
static bool rank_up(WindowObject winobj);
static Datum leadlag_common(FunctionCallInfo fcinfo,
bool forward, bool withoffset, bool withdefault);
-
+static bool get_slots(WindowObject winobj, WindowAggState *winstate, int current_pos);
+static int evaluate_pattern(WindowObject winobj, WindowAggState *winstate,
+ int relpos, char *vname, char *quantifier, bool *result);
/*
* utility routine for *_rank functions.
@@ -713,3 +727,289 @@ window_nth_value(PG_FUNCTION_ARGS)
PG_RETURN_DATUM(result);
}
+
+/*
+ * rpr
+ * allow to use "Row pattern recognition: WINDOW clause" (SQL:2016 R020) in
+ * the target list.
+ * Usage: SELECT rpr(colname) OVER (..)
+ * where colname is defined in PATTERN clause.
+ */
+Datum
+window_rpr(PG_FUNCTION_ARGS)
+{
+#define MAX_PATTERNS 16 /* max variables in PATTERN clause */
+
+ WindowObject winobj = PG_WINDOW_OBJECT();
+ WindowAggState *winstate = WinGetAggState(winobj);
+ Datum result;
+ bool expression_result;
+ bool isnull;
+ int relpos;
+ int64 curr_pos, markpos;
+ ListCell *lc, *lc1;
+ SkipContext *context = NULL;
+
+ curr_pos = WinGetCurrentPosition(winobj);
+ elog(DEBUG1, "rpr is called. row: " INT64_FORMAT, curr_pos);
+
+ if (winstate->rpSkipTo == ST_PAST_LAST_ROW)
+ {
+ context = (SkipContext *) WinGetPartitionLocalMemory(winobj, sizeof(SkipContext));
+ if (curr_pos < context->pos)
+ {
+ elog(DEBUG1, "skip this row: curr_pos: " INT64_FORMAT "context->pos: " INT64_FORMAT,
+ curr_pos, context->pos);
+ PG_RETURN_NULL();
+ }
+ }
+
+ /*
+ * Evaluate PATTERN until one of expressions is not true or out of frame.
+ */
+ relpos = 0;
+
+ forboth(lc, winstate->patternVariableList, lc1, winstate->patternRegexpList)
+ {
+ char *vname = strVal(lfirst(lc));
+ char *quantifier = strVal(lfirst(lc1));
+
+ elog(DEBUG1, "relpos: %d pattern vname: %s quantifier: %s", relpos, vname, quantifier);
+
+ /* evaluate row pattern against current row */
+ relpos = evaluate_pattern(winobj, winstate, relpos, vname, quantifier, &expression_result);
+
+ /*
+ * If the expression did not match, we are done.
+ */
+ if (!expression_result)
+ break;
+
+ /* out of frame? */
+ if (relpos < 0)
+ break;
+
+ /* count up relative row position */
+ relpos++;
+ }
+
+ elog(DEBUG1, "relpos: %d", relpos);
+
+ /*
+ * If current row satified the pattern, return argument expression.
+ */
+ if (expression_result)
+ {
+ result = WinGetFuncArgInFrame(winobj, 0,
+ 0, WINDOW_SEEK_HEAD, false,
+ &isnull, NULL);
+ }
+
+ /*
+ * At this point we can set mark down to current pos -2.
+ */
+ markpos = curr_pos -2;
+ elog(DEBUG1, "markpos: " INT64_FORMAT, markpos);
+ if (markpos >= 0)
+ WinSetMarkPosition(winobj, markpos);
+
+ if (expression_result)
+ {
+ if (winstate->rpSkipTo == ST_PAST_LAST_ROW)
+ {
+ context->pos += relpos;
+ elog(DEBUG1, "context->pos: " INT64_FORMAT, context->pos);
+ }
+ PG_RETURN_DATUM(result);
+ }
+
+ PG_RETURN_NULL();
+}
+
+/*
+ * Evaluate expression associated with PATTERN variable vname.
+ * relpos is relative row position in a frame (starting from 0).
+ * "quantifier" is the quatifier part of the PATTERN regular expression.
+ * Currently only '+' is allowed.
+ * result is out paramater representing the expression evaluation result
+ * is true of false.
+ * Return values are:
+ * >=0: the last match relative row position
+ * -1: current row is out of frame
+ */
+static
+int evaluate_pattern(WindowObject winobj, WindowAggState *winstate,
+ int relpos, char *vname, char *quantifier, bool *result)
+{
+ ExprContext *econtext = winstate->ss.ps.ps_ExprContext;
+ ListCell *lc1, *lc2;
+ ExprState *pat;
+ Datum eval_result;
+ int sts;
+ bool out_of_frame = false;
+ bool isnull;
+ StringInfo encoded_str = makeStringInfo();
+ char pattern_str[128];
+
+ forboth (lc1, winstate->defineVariableList, lc2, winstate->defineClauseList)
+ {
+ char *name = strVal(lfirst(lc1));
+ bool second_try_match = false;
+
+ if (strcmp(vname, name))
+ continue;
+
+ /* set expression to evaluate */
+ pat = lfirst(lc2);
+
+ for (;;)
+ {
+ if (!get_slots(winobj, winstate, relpos))
+ {
+ out_of_frame = true;
+ break; /* current row is out of frame */
+ }
+
+ /* evaluate the expression */
+ eval_result = ExecEvalExpr(pat, econtext, &isnull);
+ if (isnull)
+ {
+ /* expression is NULL */
+ elog(DEBUG1, "expression for %s is NULL at row: %d", vname, relpos);
+ break;
+ }
+ else
+ {
+ if (!DatumGetBool(eval_result))
+ {
+ /* expression is false */
+ elog(DEBUG1, "expression for %s is false at row: %d", vname, relpos);
+ break;
+ }
+ else
+ {
+ /* expression is true */
+ elog(DEBUG1, "expression for %s is true at row: %d", vname, relpos);
+ appendStringInfoChar(encoded_str, vname[0]);
+
+ /* If quantifier is "+", we need to look for more matching row */
+ if (quantifier && !strcmp(quantifier, "+"))
+ {
+ /* remember that we want to try another row */
+ second_try_match = true;
+ relpos++;
+ }
+ else
+ break;
+ }
+ }
+ }
+ if (second_try_match)
+ relpos--;
+
+ if (out_of_frame)
+ {
+ *result = false;
+ return -1;
+ }
+
+ /* build regular expression */
+ snprintf(pattern_str, sizeof(pattern_str), "%c%s", vname[0], quantifier);
+
+ /*
+ * Do regular expression matching against sequence of rows satisfying
+ * the expression using regexp_instr().
+ */
+ sts = DatumGetInt32(DirectFunctionCall2Coll(regexp_instr, DEFAULT_COLLATION_OID,
+ PointerGetDatum(cstring_to_text(encoded_str->data)),
+ PointerGetDatum(cstring_to_text(pattern_str))));
+ elog(DEBUG1, "regexp_instr returned: %d. str: %s regexp: %s",
+ sts, encoded_str->data, pattern_str);
+ *result = (sts > 0)? true : false;
+ }
+ return relpos;
+}
+
+/*
+ * Get current, previous and next tuple.
+ * Returns true if still within frame.
+ */
+static bool
+get_slots(WindowObject winobj, WindowAggState *winstate, int current_pos)
+{
+ TupleTableSlot *slot;
+ bool isnull, isout;
+ int sts;
+ ExprContext *econtext;
+
+ econtext = winstate->ss.ps.ps_ExprContext;
+
+ /* for current row */
+ slot = winstate->temp_slot_1;
+ sts = WinGetSlotInFrame(winobj, slot,
+ current_pos, WINDOW_SEEK_HEAD, false,
+ &isnull, &isout);
+ if (sts < 0)
+ {
+ elog(DEBUG1, "current row is out of frame");
+ econtext->ecxt_scantuple = winstate->null_slot;
+ return false;
+ }
+ else
+ econtext->ecxt_scantuple = slot;
+
+ /* for PREV */
+ if (current_pos > 0)
+ {
+ slot = winstate->prev_slot;
+ sts = WinGetSlotInFrame(winobj, slot,
+ current_pos - 1, WINDOW_SEEK_HEAD, false,
+ &isnull, &isout);
+ if (sts < 0)
+ {
+ elog(DEBUG1, "previous row out of frame at: %d", current_pos);
+ econtext->ecxt_outertuple = winstate->null_slot;
+ }
+ econtext->ecxt_outertuple = slot;
+ }
+ else
+ econtext->ecxt_outertuple = winstate->null_slot;
+
+ /* for NEXT */
+ slot = winstate->next_slot;
+ sts = WinGetSlotInFrame(winobj, slot,
+ current_pos + 1, WINDOW_SEEK_HEAD, false,
+ &isnull, &isout);
+ if (sts < 0)
+ {
+ elog(DEBUG1, "next row out of frame at: %d", current_pos);
+ econtext->ecxt_innertuple = winstate->null_slot;
+ }
+ else
+ econtext->ecxt_innertuple = slot;
+
+ return true;
+}
+
+/*
+ * prev
+ * Dummy function to invoke RPR's navigation operator "PREV".
+ * This is *not* a window function.
+ */
+Datum
+window_prev(PG_FUNCTION_ARGS)
+{
+ PG_RETURN_DATUM(PG_GETARG_DATUM(0));
+}
+
+/*
+ * next
+ * Dummy function to invoke RPR's navigation operation "NEXT".
+ * This is *not* a window function.
+ */
+Datum
+window_next(PG_FUNCTION_ARGS)
+{
+ PG_RETURN_DATUM(PG_GETARG_DATUM(0));
+}
+
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 6996073989..e3a9e0ffeb 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10397,6 +10397,15 @@
{ oid => '3114', descr => 'fetch the Nth row value',
proname => 'nth_value', prokind => 'w', prorettype => 'anyelement',
proargtypes => 'anyelement int4', prosrc => 'window_nth_value' },
+{ oid => '6122', descr => 'row pattern recognition in window',
+ proname => 'rpr', prokind => 'w', prorettype => 'anyelement',
+ proargtypes => 'anyelement', prosrc => 'window_rpr' },
+{ oid => '6123', descr => 'previous value',
+ proname => 'prev', provolatile => 's', prorettype => 'anyelement',
+ proargtypes => 'anyelement', prosrc => 'window_prev' },
+{ oid => '6124', descr => 'next value',
+ proname => 'next', provolatile => 's', prorettype => 'anyelement',
+ proargtypes => 'anyelement', prosrc => 'window_next' },
# functions for range types
{ oid => '3832', descr => 'I/O',
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index cb714f4a19..1643eaa6f1 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -2519,6 +2519,14 @@ typedef struct WindowAggState
int64 groupheadpos; /* current row's peer group head position */
int64 grouptailpos; /* " " " " tail position (group end+1) */
+ /* these fields are used in Row pattern recognition: */
+ RPSkipTo rpSkipTo; /* Row Pattern Skip To type */
+ List *patternVariableList; /* list of row pattern variables names (list of String) */
+ List *patternRegexpList; /* list of row pattern regular expressions ('+' or ''. list of String) */
+ List *defineVariableList; /* list of row pattern definition variables (list of String) */
+ List *defineClauseList; /* expression for row pattern definition
+ * search conditions ExprState list */
+
MemoryContext partcontext; /* context for partition-lifespan data */
MemoryContext aggcontext; /* shared context for aggregate working data */
MemoryContext curaggcontext; /* current aggregate's working data */
@@ -2555,6 +2563,11 @@ typedef struct WindowAggState
TupleTableSlot *agg_row_slot;
TupleTableSlot *temp_slot_1;
TupleTableSlot *temp_slot_2;
+
+ /* temporary slots for RPR */
+ TupleTableSlot *prev_slot; /* PREV row navigation operator */
+ TupleTableSlot *next_slot; /* NEXT row navigation operator */
+ TupleTableSlot *null_slot; /* all NULL slot */
} WindowAggState;
/* ----------------
diff --git a/src/include/windowapi.h b/src/include/windowapi.h
index b8c2c565d1..a0facf38fe 100644
--- a/src/include/windowapi.h
+++ b/src/include/windowapi.h
@@ -58,7 +58,16 @@ extern Datum WinGetFuncArgInFrame(WindowObject winobj, int argno,
int relpos, int seektype, bool set_mark,
bool *isnull, bool *isout);
+extern int WinGetSlotInFrame(WindowObject winobj, TupleTableSlot *slot,
+ int relpos, int seektype, bool set_mark,
+ bool *isnull, bool *isout);
+
extern Datum WinGetFuncArgCurrent(WindowObject winobj, int argno,
bool *isnull);
+extern WindowAggState *WinGetAggState(WindowObject winobj);
+
+extern bool window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot);
+
+
#endif /* WINDOWAPI_H */
--
2.25.1
----Next_Part(Mon_Jun_26_17_45_07_2023_724)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="v2-0005-Row-pattern-recognition-patch-docs.patch"
^ permalink raw reply [nested|flat] 36+ messages in thread
end of thread, other threads:[~2023-06-26 08:05 UTC | newest]
Thread overview: 36+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2021-01-08 23:56 [PATCH 2/2] fixup: rename defined to requested Tomas Vondra <[email protected]>
2022-10-12 09:19 Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <[email protected]>
2022-10-12 11:29 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <[email protected]>
2022-10-12 20:41 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <[email protected]>
2022-10-13 03:39 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <[email protected]>
2022-10-12 12:13 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <[email protected]>
2022-10-12 20:50 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <[email protected]>
2022-10-13 03:47 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <[email protected]>
2022-10-13 06:48 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <[email protected]>
2022-10-13 08:17 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <[email protected]>
2022-10-13 10:43 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <[email protected]>
2022-10-14 02:14 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <[email protected]>
2022-10-26 08:25 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <[email protected]>
2022-10-27 02:50 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <[email protected]>
2022-10-28 10:17 ` Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <[email protected]>
2023-06-26 08:05 [PATCH v2 4/7] Row pattern recognition patch (executor). Tatsuo Ishii <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox