pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Avoid pushing quals down into sub-queries that have grouping set
7+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid pushing quals down into sub-queries that have grouping set
@ 2020-08-22 18:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-08-22 18:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid pushing quals down into sub-queries that have grouping sets.

The trouble with doing this is that an apparently-constant subquery
output column isn't really constant if it is a grouping column that
appears in only some of the grouping sets.  A qual using such a
column would be subject to incorrect const-folding after push-down,
as seen in bug #16585 from Paul Sivash.

To fix, just disable qual pushdown altogether if the sub-query has
nonempty groupingSets.  While we could imagine far less restrictive
solutions, there is not much point in working harder right now,
because subquery_planner() won't move HAVING clauses to WHERE within
such a subquery.  If the qual stays in HAVING it's not going to be
a lot more useful than if we'd kept it at the outer level.

Having said that, this restriction could be removed if we used a
parsetree representation that distinguished such outputs from actual
constants, which is something I hope to do in future.  Hence, make
the patch a minimal addition rather than integrating it more tightly
(e.g. by renumbering the existing items in subquery_is_pushdown_safe's
comment).

Back-patch to 9.5 where grouping sets were introduced.

Discussion: https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4d346def1555ea55b3adf76fc4afa3d3495ecfdd

Modified Files
--------------
src/backend/optimizer/path/allpaths.c      | 15 ++++++++++++++
src/test/regress/expected/groupingsets.out | 32 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      | 16 +++++++++++++++
3 files changed, 63 insertions(+)



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

* pgsql: Avoid pushing quals down into sub-queries that have grouping set
@ 2020-08-22 18:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-08-22 18:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid pushing quals down into sub-queries that have grouping sets.

The trouble with doing this is that an apparently-constant subquery
output column isn't really constant if it is a grouping column that
appears in only some of the grouping sets.  A qual using such a
column would be subject to incorrect const-folding after push-down,
as seen in bug #16585 from Paul Sivash.

To fix, just disable qual pushdown altogether if the sub-query has
nonempty groupingSets.  While we could imagine far less restrictive
solutions, there is not much point in working harder right now,
because subquery_planner() won't move HAVING clauses to WHERE within
such a subquery.  If the qual stays in HAVING it's not going to be
a lot more useful than if we'd kept it at the outer level.

Having said that, this restriction could be removed if we used a
parsetree representation that distinguished such outputs from actual
constants, which is something I hope to do in future.  Hence, make
the patch a minimal addition rather than integrating it more tightly
(e.g. by renumbering the existing items in subquery_is_pushdown_safe's
comment).

Back-patch to 9.5 where grouping sets were introduced.

Discussion: https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org

Branch
------
REL_13_STABLE

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

Modified Files
--------------
src/backend/optimizer/path/allpaths.c      | 15 ++++++++++++++
src/test/regress/expected/groupingsets.out | 32 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      | 16 +++++++++++++++
3 files changed, 63 insertions(+)



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

* pgsql: Avoid pushing quals down into sub-queries that have grouping set
@ 2020-08-22 18:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-08-22 18:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid pushing quals down into sub-queries that have grouping sets.

The trouble with doing this is that an apparently-constant subquery
output column isn't really constant if it is a grouping column that
appears in only some of the grouping sets.  A qual using such a
column would be subject to incorrect const-folding after push-down,
as seen in bug #16585 from Paul Sivash.

To fix, just disable qual pushdown altogether if the sub-query has
nonempty groupingSets.  While we could imagine far less restrictive
solutions, there is not much point in working harder right now,
because subquery_planner() won't move HAVING clauses to WHERE within
such a subquery.  If the qual stays in HAVING it's not going to be
a lot more useful than if we'd kept it at the outer level.

Having said that, this restriction could be removed if we used a
parsetree representation that distinguished such outputs from actual
constants, which is something I hope to do in future.  Hence, make
the patch a minimal addition rather than integrating it more tightly
(e.g. by renumbering the existing items in subquery_is_pushdown_safe's
comment).

Back-patch to 9.5 where grouping sets were introduced.

Discussion: https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6b701eaaa90e07035f9a965d7ca9831d01586c63

Modified Files
--------------
src/backend/optimizer/path/allpaths.c      | 15 ++++++++++++++
src/test/regress/expected/groupingsets.out | 32 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      | 16 +++++++++++++++
3 files changed, 63 insertions(+)



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

* pgsql: Avoid pushing quals down into sub-queries that have grouping set
@ 2020-08-22 18:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-08-22 18:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid pushing quals down into sub-queries that have grouping sets.

The trouble with doing this is that an apparently-constant subquery
output column isn't really constant if it is a grouping column that
appears in only some of the grouping sets.  A qual using such a
column would be subject to incorrect const-folding after push-down,
as seen in bug #16585 from Paul Sivash.

To fix, just disable qual pushdown altogether if the sub-query has
nonempty groupingSets.  While we could imagine far less restrictive
solutions, there is not much point in working harder right now,
because subquery_planner() won't move HAVING clauses to WHERE within
such a subquery.  If the qual stays in HAVING it's not going to be
a lot more useful than if we'd kept it at the outer level.

Having said that, this restriction could be removed if we used a
parsetree representation that distinguished such outputs from actual
constants, which is something I hope to do in future.  Hence, make
the patch a minimal addition rather than integrating it more tightly
(e.g. by renumbering the existing items in subquery_is_pushdown_safe's
comment).

Back-patch to 9.5 where grouping sets were introduced.

Discussion: https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/optimizer/path/allpaths.c      | 15 ++++++++++++++
src/test/regress/expected/groupingsets.out | 32 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      | 16 +++++++++++++++
3 files changed, 63 insertions(+)



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

* pgsql: Avoid pushing quals down into sub-queries that have grouping set
@ 2020-08-22 18:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-08-22 18:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid pushing quals down into sub-queries that have grouping sets.

The trouble with doing this is that an apparently-constant subquery
output column isn't really constant if it is a grouping column that
appears in only some of the grouping sets.  A qual using such a
column would be subject to incorrect const-folding after push-down,
as seen in bug #16585 from Paul Sivash.

To fix, just disable qual pushdown altogether if the sub-query has
nonempty groupingSets.  While we could imagine far less restrictive
solutions, there is not much point in working harder right now,
because subquery_planner() won't move HAVING clauses to WHERE within
such a subquery.  If the qual stays in HAVING it's not going to be
a lot more useful than if we'd kept it at the outer level.

Having said that, this restriction could be removed if we used a
parsetree representation that distinguished such outputs from actual
constants, which is something I hope to do in future.  Hence, make
the patch a minimal addition rather than integrating it more tightly
(e.g. by renumbering the existing items in subquery_is_pushdown_safe's
comment).

Back-patch to 9.5 where grouping sets were introduced.

Discussion: https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6fa403e61241bea60db83ce13ebcea7d6dda3024

Modified Files
--------------
src/backend/optimizer/path/allpaths.c      | 15 ++++++++++++++
src/test/regress/expected/groupingsets.out | 32 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      | 16 +++++++++++++++
3 files changed, 63 insertions(+)



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

* pgsql: Avoid pushing quals down into sub-queries that have grouping set
@ 2020-08-22 18:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-08-22 18:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid pushing quals down into sub-queries that have grouping sets.

The trouble with doing this is that an apparently-constant subquery
output column isn't really constant if it is a grouping column that
appears in only some of the grouping sets.  A qual using such a
column would be subject to incorrect const-folding after push-down,
as seen in bug #16585 from Paul Sivash.

To fix, just disable qual pushdown altogether if the sub-query has
nonempty groupingSets.  While we could imagine far less restrictive
solutions, there is not much point in working harder right now,
because subquery_planner() won't move HAVING clauses to WHERE within
such a subquery.  If the qual stays in HAVING it's not going to be
a lot more useful than if we'd kept it at the outer level.

Having said that, this restriction could be removed if we used a
parsetree representation that distinguished such outputs from actual
constants, which is something I hope to do in future.  Hence, make
the patch a minimal addition rather than integrating it more tightly
(e.g. by renumbering the existing items in subquery_is_pushdown_safe's
comment).

Back-patch to 9.5 where grouping sets were introduced.

Discussion: https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org

Branch
------
REL9_6_STABLE

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

Modified Files
--------------
src/backend/optimizer/path/allpaths.c      | 15 ++++++++++++++
src/test/regress/expected/groupingsets.out | 32 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      | 16 +++++++++++++++
3 files changed, 63 insertions(+)



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

* pgsql: Avoid pushing quals down into sub-queries that have grouping set
@ 2020-08-22 18:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-08-22 18:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid pushing quals down into sub-queries that have grouping sets.

The trouble with doing this is that an apparently-constant subquery
output column isn't really constant if it is a grouping column that
appears in only some of the grouping sets.  A qual using such a
column would be subject to incorrect const-folding after push-down,
as seen in bug #16585 from Paul Sivash.

To fix, just disable qual pushdown altogether if the sub-query has
nonempty groupingSets.  While we could imagine far less restrictive
solutions, there is not much point in working harder right now,
because subquery_planner() won't move HAVING clauses to WHERE within
such a subquery.  If the qual stays in HAVING it's not going to be
a lot more useful than if we'd kept it at the outer level.

Having said that, this restriction could be removed if we used a
parsetree representation that distinguished such outputs from actual
constants, which is something I hope to do in future.  Hence, make
the patch a minimal addition rather than integrating it more tightly
(e.g. by renumbering the existing items in subquery_is_pushdown_safe's
comment).

Back-patch to 9.5 where grouping sets were introduced.

Discussion: https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7edd36eae1fd0b256a55698a16a922c4ebfac88c

Modified Files
--------------
src/backend/optimizer/path/allpaths.c      | 15 ++++++++++++++
src/test/regress/expected/groupingsets.out | 32 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      | 16 +++++++++++++++
3 files changed, 63 insertions(+)



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


end of thread, other threads:[~2020-08-22 18:47 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 18:47 pgsql: Avoid pushing quals down into sub-queries that have grouping set Tom Lane <tgl@sss.pgh.pa.us>
2020-08-22 18:47 pgsql: Avoid pushing quals down into sub-queries that have grouping set Tom Lane <tgl@sss.pgh.pa.us>
2020-08-22 18:47 pgsql: Avoid pushing quals down into sub-queries that have grouping set Tom Lane <tgl@sss.pgh.pa.us>
2020-08-22 18:47 pgsql: Avoid pushing quals down into sub-queries that have grouping set Tom Lane <tgl@sss.pgh.pa.us>
2020-08-22 18:47 pgsql: Avoid pushing quals down into sub-queries that have grouping set Tom Lane <tgl@sss.pgh.pa.us>
2020-08-22 18:47 pgsql: Avoid pushing quals down into sub-queries that have grouping set Tom Lane <tgl@sss.pgh.pa.us>
2020-08-22 18:47 pgsql: Avoid pushing quals down into sub-queries that have grouping set Tom Lane <tgl@sss.pgh.pa.us>

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