pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Build inherited extended stats on partitioned tables
6+ messages / 1 participants
[nested] [flat]

* pgsql: Build inherited extended stats on partitioned tables
@ 2022-01-15 18:27 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tomas Vondra @ 2022-01-15 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Build inherited extended stats on partitioned tables

Commit 859b3003de disabled building of extended stats for inheritance
trees, to prevent updating the same catalog row twice. While that
resolved the issue, it also means there are no extended stats for
declaratively partitioned tables, because there are no data in the
non-leaf relations.

That also means declaratively partitioned tables were not affected by
the issue 859b3003de addressed, which means this is a regression
affecting queries that calculate estimates for the whole inheritance
tree as a whole (which includes e.g. GROUP BY queries).

But because partitioned tables are empty, we can invert the condition
and build statistics only for the case with inheritance, without losing
anything. And we can consider them when calculating estimates.

It may be necessary to run ANALYZE on partitioned tables, to collect
proper statistics. For declarative partitioning there should no prior
statistics, and it might take time before autoanalyze is triggered. For
tables partitioned by inheritance the statistics may include data from
child relations (if built 859b3003de), contradicting the current code.

Report and patch by Justin Pryzby, minor fixes and cleanup by me.
Backpatch all the way back to PostgreSQL 10, where extended statistics
were introduced (same as 859b3003de).

Author: Justin Pryzby
Reported-by: Justin Pryzby
Backpatch-through: 10
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/20b9fa308ebf7d4a26ac53804fce1c30f781d60c

Modified Files
--------------
src/backend/commands/analyze.c          | 18 +++++++++++++++++-
src/backend/statistics/dependencies.c   |  9 ++++++---
src/backend/statistics/extended_stats.c |  9 ++++++---
src/backend/utils/adt/selfuncs.c        | 31 +++++++++++++++++++------------
src/test/regress/expected/stats_ext.out | 19 +++++++++++++++++++
src/test/regress/sql/stats_ext.sql      | 10 ++++++++++
6 files changed, 77 insertions(+), 19 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Build inherited extended stats on partitioned tables
@ 2022-01-15 18:27 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tomas Vondra @ 2022-01-15 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Build inherited extended stats on partitioned tables

Commit 859b3003de disabled building of extended stats for inheritance
trees, to prevent updating the same catalog row twice. While that
resolved the issue, it also means there are no extended stats for
declaratively partitioned tables, because there are no data in the
non-leaf relations.

That also means declaratively partitioned tables were not affected by
the issue 859b3003de addressed, which means this is a regression
affecting queries that calculate estimates for the whole inheritance
tree as a whole (which includes e.g. GROUP BY queries).

But because partitioned tables are empty, we can invert the condition
and build statistics only for the case with inheritance, without losing
anything. And we can consider them when calculating estimates.

It may be necessary to run ANALYZE on partitioned tables, to collect
proper statistics. For declarative partitioning there should no prior
statistics, and it might take time before autoanalyze is triggered. For
tables partitioned by inheritance the statistics may include data from
child relations (if built 859b3003de), contradicting the current code.

Report and patch by Justin Pryzby, minor fixes and cleanup by me.
Backpatch all the way back to PostgreSQL 10, where extended statistics
were introduced (same as 859b3003de).

Author: Justin Pryzby
Reported-by: Justin Pryzby
Backpatch-through: 10
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ea212bd95fd2456953ca8995cf2a04d3db82ac19

Modified Files
--------------
src/backend/commands/analyze.c          | 18 +++++++++++++++++-
src/backend/statistics/dependencies.c   |  9 ++++++---
src/backend/statistics/extended_stats.c |  9 ++++++---
src/backend/utils/adt/selfuncs.c        | 31 +++++++++++++++++++------------
src/test/regress/expected/stats_ext.out | 19 +++++++++++++++++++
src/test/regress/sql/stats_ext.sql      | 10 ++++++++++
6 files changed, 77 insertions(+), 19 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Build inherited extended stats on partitioned tables
@ 2022-01-15 18:27 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tomas Vondra @ 2022-01-15 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Build inherited extended stats on partitioned tables

Commit 859b3003de disabled building of extended stats for inheritance
trees, to prevent updating the same catalog row twice. While that
resolved the issue, it also means there are no extended stats for
declaratively partitioned tables, because there are no data in the
non-leaf relations.

That also means declaratively partitioned tables were not affected by
the issue 859b3003de addressed, which means this is a regression
affecting queries that calculate estimates for the whole inheritance
tree as a whole (which includes e.g. GROUP BY queries).

But because partitioned tables are empty, we can invert the condition
and build statistics only for the case with inheritance, without losing
anything. And we can consider them when calculating estimates.

It may be necessary to run ANALYZE on partitioned tables, to collect
proper statistics. For declarative partitioning there should no prior
statistics, and it might take time before autoanalyze is triggered. For
tables partitioned by inheritance the statistics may include data from
child relations (if built 859b3003de), contradicting the current code.

Report and patch by Justin Pryzby, minor fixes and cleanup by me.
Backpatch all the way back to PostgreSQL 10, where extended statistics
were introduced (same as 859b3003de).

Author: Justin Pryzby
Reported-by: Justin Pryzby
Backpatch-through: 10
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d6817032d26becd3c49f11d16efd6012e2139fc4

Modified Files
--------------
src/backend/commands/analyze.c          | 18 +++++++++++++++++-
src/backend/statistics/dependencies.c   |  9 ++++++---
src/backend/statistics/extended_stats.c |  9 ++++++---
src/backend/utils/adt/selfuncs.c        | 20 ++++++++++++--------
src/test/regress/expected/stats_ext.out | 19 +++++++++++++++++++
src/test/regress/sql/stats_ext.sql      | 10 ++++++++++
6 files changed, 70 insertions(+), 15 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Build inherited extended stats on partitioned tables
@ 2022-01-15 18:27 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tomas Vondra @ 2022-01-15 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Build inherited extended stats on partitioned tables

Commit 859b3003de disabled building of extended stats for inheritance
trees, to prevent updating the same catalog row twice. While that
resolved the issue, it also means there are no extended stats for
declaratively partitioned tables, because there are no data in the
non-leaf relations.

That also means declaratively partitioned tables were not affected by
the issue 859b3003de addressed, which means this is a regression
affecting queries that calculate estimates for the whole inheritance
tree as a whole (which includes e.g. GROUP BY queries).

But because partitioned tables are empty, we can invert the condition
and build statistics only for the case with inheritance, without losing
anything. And we can consider them when calculating estimates.

It may be necessary to run ANALYZE on partitioned tables, to collect
proper statistics. For declarative partitioning there should no prior
statistics, and it might take time before autoanalyze is triggered. For
tables partitioned by inheritance the statistics may include data from
child relations (if built 859b3003de), contradicting the current code.

Report and patch by Justin Pryzby, minor fixes and cleanup by me.
Backpatch all the way back to PostgreSQL 10, where extended statistics
were introduced (same as 859b3003de).

Author: Justin Pryzby
Reported-by: Justin Pryzby
Backpatch-through: 10
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9d1bcf5dc11a932e0a88710c34815c86dc583fcc

Modified Files
--------------
src/backend/commands/analyze.c          | 18 +++++++++++++++++-
src/backend/statistics/dependencies.c   |  9 ++++++---
src/backend/statistics/extended_stats.c |  9 ++++++---
src/backend/utils/adt/selfuncs.c        | 20 ++++++++++++--------
src/test/regress/expected/stats_ext.out | 19 +++++++++++++++++++
src/test/regress/sql/stats_ext.sql      | 10 ++++++++++
6 files changed, 70 insertions(+), 15 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Build inherited extended stats on partitioned tables
@ 2022-01-15 18:27 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tomas Vondra @ 2022-01-15 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Build inherited extended stats on partitioned tables

Commit 859b3003de disabled building of extended stats for inheritance
trees, to prevent updating the same catalog row twice. While that
resolved the issue, it also means there are no extended stats for
declaratively partitioned tables, because there are no data in the
non-leaf relations.

That also means declaratively partitioned tables were not affected by
the issue 859b3003de addressed, which means this is a regression
affecting queries that calculate estimates for the whole inheritance
tree as a whole (which includes e.g. GROUP BY queries).

But because partitioned tables are empty, we can invert the condition
and build statistics only for the case with inheritance, without losing
anything. And we can consider them when calculating estimates.

It may be necessary to run ANALYZE on partitioned tables, to collect
proper statistics. For declarative partitioning there should no prior
statistics, and it might take time before autoanalyze is triggered. For
tables partitioned by inheritance the statistics may include data from
child relations (if built 859b3003de), contradicting the current code.

Report and patch by Justin Pryzby, minor fixes and cleanup by me.
Backpatch all the way back to PostgreSQL 10, where extended statistics
were introduced (same as 859b3003de).

Author: Justin Pryzby
Reported-by: Justin Pryzby
Backpatch-through: 10
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/491182e52909564ce2fe9bc9c5f8ae6640682b30

Modified Files
--------------
src/backend/commands/analyze.c          | 18 +++++++++++++++++-
src/backend/statistics/dependencies.c   | 10 +++++++---
src/backend/utils/adt/selfuncs.c        | 20 ++++++++++++--------
src/test/regress/expected/stats_ext.out | 19 +++++++++++++++++++
src/test/regress/sql/stats_ext.sql      | 10 ++++++++++
5 files changed, 65 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Build inherited extended stats on partitioned tables
@ 2022-01-15 18:28 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tomas Vondra @ 2022-01-15 18:28 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Build inherited extended stats on partitioned tables

Commit 859b3003de disabled building of extended stats for inheritance
trees, to prevent updating the same catalog row twice. While that
resolved the issue, it also means there are no extended stats for
declaratively partitioned tables, because there are no data in the
non-leaf relations.

That also means declaratively partitioned tables were not affected by
the issue 859b3003de addressed, which means this is a regression
affecting queries that calculate estimates for the whole inheritance
tree as a whole (which includes e.g. GROUP BY queries).

But because partitioned tables are empty, we can invert the condition
and build statistics only for the case with inheritance, without losing
anything. And we can consider them when calculating estimates.

It may be necessary to run ANALYZE on partitioned tables, to collect
proper statistics. For declarative partitioning there should no prior
statistics, and it might take time before autoanalyze is triggered. For
tables partitioned by inheritance the statistics may include data from
child relations (if built 859b3003de), contradicting the current code.

Report and patch by Justin Pryzby, minor fixes and cleanup by me.
Backpatch all the way back to PostgreSQL 10, where extended statistics
were introduced (same as 859b3003de).

Author: Justin Pryzby
Reported-by: Justin Pryzby
Backpatch-through: 10
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9211c2e38f099d97d14b5556d7afc76bef083783

Modified Files
--------------
src/backend/commands/analyze.c          | 18 +++++++++++++++++-
src/backend/statistics/dependencies.c   | 10 +++++++---
src/backend/utils/adt/selfuncs.c        | 20 ++++++++++++--------
src/test/regress/expected/stats_ext.out | 19 +++++++++++++++++++
src/test/regress/sql/stats_ext.sql      | 10 ++++++++++
5 files changed, 65 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2022-01-15 18:28 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-15 18:27 pgsql: Build inherited extended stats on partitioned tables Tomas Vondra <tomas.vondra@postgresql.org>
2022-01-15 18:27 pgsql: Build inherited extended stats on partitioned tables Tomas Vondra <tomas.vondra@postgresql.org>
2022-01-15 18:27 pgsql: Build inherited extended stats on partitioned tables Tomas Vondra <tomas.vondra@postgresql.org>
2022-01-15 18:27 pgsql: Build inherited extended stats on partitioned tables Tomas Vondra <tomas.vondra@postgresql.org>
2022-01-15 18:27 pgsql: Build inherited extended stats on partitioned tables Tomas Vondra <tomas.vondra@postgresql.org>
2022-01-15 18:28 pgsql: Build inherited extended stats on partitioned tables Tomas Vondra <tomas.vondra@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox