pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix index-only scan plans, take 2. 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix index-only scan plans, take 2. @ 2022-01-03 20:42 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-01-03 20:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix index-only scan plans, take 2. Commit 4ace45677 failed to fix the problem fully, because the same issue of attempting to fetch a non-returnable index column can occur when rechecking the indexqual after using a lossy index operator. Moreover, it broke EXPLAIN for such indexquals (which indicates a gap in our test cases :-(). Revert the code changes of 4ace45677 in favor of adding a new field to struct IndexOnlyScan, containing a version of the indexqual that can be executed against the index-returned tuple without using any non-returnable columns. (The restrictions imposed by check_index_only guarantee this is possible, although we may have to recompute indexed expressions.) Support construction of that during setrefs.c processing by marking IndexOnlyScan.indextlist entries as resjunk if they can't be returned, rather than removing them entirely. (We could alternatively require setrefs.c to look up the IndexOptInfo again, but abusing resjunk this way seems like a reasonably safe way to avoid needing to do that.) This solution isn't great from an API-stability standpoint: if there are any extensions out there that build IndexOnlyScan structs directly, they'll be broken in the next minor releases. However, only a very invasive extension would be likely to do such a thing. There's no change in the Path representation, so typical planner extensions shouldn't have a problem. As before, back-patch to all supported branches. Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d228af79d0f206f9bd24856b2c1df0909c8db1ec Modified Files -------------- src/backend/commands/explain.c | 2 +- src/backend/executor/nodeIndexonlyscan.c | 8 ++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/nodes/readfuncs.c | 1 + src/backend/optimizer/plan/createplan.c | 80 +++++++++++--------------------- src/backend/optimizer/plan/setrefs.c | 27 ++++++++++- src/backend/optimizer/plan/subselect.c | 2 + src/include/nodes/execnodes.h | 4 +- src/include/nodes/plannodes.h | 22 +++++++-- src/test/regress/expected/gist.out | 31 +++++++++++++ src/test/regress/sql/gist.sql | 11 +++++ 12 files changed, 124 insertions(+), 66 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix index-only scan plans, take 2. @ 2022-01-03 20:42 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-01-03 20:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix index-only scan plans, take 2. Commit 4ace45677 failed to fix the problem fully, because the same issue of attempting to fetch a non-returnable index column can occur when rechecking the indexqual after using a lossy index operator. Moreover, it broke EXPLAIN for such indexquals (which indicates a gap in our test cases :-(). Revert the code changes of 4ace45677 in favor of adding a new field to struct IndexOnlyScan, containing a version of the indexqual that can be executed against the index-returned tuple without using any non-returnable columns. (The restrictions imposed by check_index_only guarantee this is possible, although we may have to recompute indexed expressions.) Support construction of that during setrefs.c processing by marking IndexOnlyScan.indextlist entries as resjunk if they can't be returned, rather than removing them entirely. (We could alternatively require setrefs.c to look up the IndexOptInfo again, but abusing resjunk this way seems like a reasonably safe way to avoid needing to do that.) This solution isn't great from an API-stability standpoint: if there are any extensions out there that build IndexOnlyScan structs directly, they'll be broken in the next minor releases. However, only a very invasive extension would be likely to do such a thing. There's no change in the Path representation, so typical planner extensions shouldn't have a problem. As before, back-patch to all supported branches. Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9a3ddeb519e8d91b670fa923619b212a9670389c Modified Files -------------- src/backend/commands/explain.c | 2 +- src/backend/executor/nodeIndexonlyscan.c | 8 ++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/nodes/readfuncs.c | 1 + src/backend/optimizer/plan/createplan.c | 80 +++++++++++--------------------- src/backend/optimizer/plan/setrefs.c | 27 ++++++++++- src/backend/optimizer/plan/subselect.c | 2 + src/include/nodes/execnodes.h | 4 +- src/include/nodes/plannodes.h | 22 +++++++-- src/test/regress/expected/gist.out | 31 +++++++++++++ src/test/regress/sql/gist.sql | 11 +++++ 12 files changed, 124 insertions(+), 66 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix index-only scan plans, take 2. @ 2022-01-03 20:42 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-01-03 20:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix index-only scan plans, take 2. Commit 4ace45677 failed to fix the problem fully, because the same issue of attempting to fetch a non-returnable index column can occur when rechecking the indexqual after using a lossy index operator. Moreover, it broke EXPLAIN for such indexquals (which indicates a gap in our test cases :-(). Revert the code changes of 4ace45677 in favor of adding a new field to struct IndexOnlyScan, containing a version of the indexqual that can be executed against the index-returned tuple without using any non-returnable columns. (The restrictions imposed by check_index_only guarantee this is possible, although we may have to recompute indexed expressions.) Support construction of that during setrefs.c processing by marking IndexOnlyScan.indextlist entries as resjunk if they can't be returned, rather than removing them entirely. (We could alternatively require setrefs.c to look up the IndexOptInfo again, but abusing resjunk this way seems like a reasonably safe way to avoid needing to do that.) This solution isn't great from an API-stability standpoint: if there are any extensions out there that build IndexOnlyScan structs directly, they'll be broken in the next minor releases. However, only a very invasive extension would be likely to do such a thing. There's no change in the Path representation, so typical planner extensions shouldn't have a problem. As before, back-patch to all supported branches. Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/20d08b2c61cd7f224739a52fb069e93abe5d448d Modified Files -------------- src/backend/commands/explain.c | 2 +- src/backend/executor/nodeIndexonlyscan.c | 8 ++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/nodes/readfuncs.c | 1 + src/backend/optimizer/plan/createplan.c | 80 +++++++++++--------------------- src/backend/optimizer/plan/setrefs.c | 26 ++++++++++- src/backend/optimizer/plan/subselect.c | 2 + src/include/nodes/execnodes.h | 4 +- src/include/nodes/plannodes.h | 22 +++++++-- src/test/regress/expected/gist.out | 31 +++++++++++++ src/test/regress/sql/gist.sql | 11 +++++ 12 files changed, 123 insertions(+), 66 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix index-only scan plans, take 2. @ 2022-01-03 20:42 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-01-03 20:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix index-only scan plans, take 2. Commit 4ace45677 failed to fix the problem fully, because the same issue of attempting to fetch a non-returnable index column can occur when rechecking the indexqual after using a lossy index operator. Moreover, it broke EXPLAIN for such indexquals (which indicates a gap in our test cases :-(). Revert the code changes of 4ace45677 in favor of adding a new field to struct IndexOnlyScan, containing a version of the indexqual that can be executed against the index-returned tuple without using any non-returnable columns. (The restrictions imposed by check_index_only guarantee this is possible, although we may have to recompute indexed expressions.) Support construction of that during setrefs.c processing by marking IndexOnlyScan.indextlist entries as resjunk if they can't be returned, rather than removing them entirely. (We could alternatively require setrefs.c to look up the IndexOptInfo again, but abusing resjunk this way seems like a reasonably safe way to avoid needing to do that.) This solution isn't great from an API-stability standpoint: if there are any extensions out there that build IndexOnlyScan structs directly, they'll be broken in the next minor releases. However, only a very invasive extension would be likely to do such a thing. There's no change in the Path representation, so typical planner extensions shouldn't have a problem. As before, back-patch to all supported branches. Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7d344f00413acc985977e2db1ddceb37452a2b98 Modified Files -------------- src/backend/commands/explain.c | 2 +- src/backend/executor/nodeIndexonlyscan.c | 8 ++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/nodes/readfuncs.c | 1 + src/backend/optimizer/plan/createplan.c | 80 +++++++++++--------------------- src/backend/optimizer/plan/setrefs.c | 26 ++++++++++- src/backend/optimizer/plan/subselect.c | 2 + src/include/nodes/execnodes.h | 4 +- src/include/nodes/plannodes.h | 22 +++++++-- src/test/regress/expected/gist.out | 31 +++++++++++++ src/test/regress/sql/gist.sql | 11 +++++ 12 files changed, 123 insertions(+), 66 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix index-only scan plans, take 2. @ 2022-01-03 20:42 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-01-03 20:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix index-only scan plans, take 2. Commit 4ace45677 failed to fix the problem fully, because the same issue of attempting to fetch a non-returnable index column can occur when rechecking the indexqual after using a lossy index operator. Moreover, it broke EXPLAIN for such indexquals (which indicates a gap in our test cases :-(). Revert the code changes of 4ace45677 in favor of adding a new field to struct IndexOnlyScan, containing a version of the indexqual that can be executed against the index-returned tuple without using any non-returnable columns. (The restrictions imposed by check_index_only guarantee this is possible, although we may have to recompute indexed expressions.) Support construction of that during setrefs.c processing by marking IndexOnlyScan.indextlist entries as resjunk if they can't be returned, rather than removing them entirely. (We could alternatively require setrefs.c to look up the IndexOptInfo again, but abusing resjunk this way seems like a reasonably safe way to avoid needing to do that.) This solution isn't great from an API-stability standpoint: if there are any extensions out there that build IndexOnlyScan structs directly, they'll be broken in the next minor releases. However, only a very invasive extension would be likely to do such a thing. There's no change in the Path representation, so typical planner extensions shouldn't have a problem. As before, back-patch to all supported branches. Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ec367452179c9b62e8d578c9abfab953838fb01d Modified Files -------------- src/backend/commands/explain.c | 2 +- src/backend/executor/nodeIndexonlyscan.c | 8 ++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/nodes/readfuncs.c | 1 + src/backend/optimizer/plan/createplan.c | 80 +++++++++++--------------------- src/backend/optimizer/plan/setrefs.c | 26 ++++++++++- src/backend/optimizer/plan/subselect.c | 2 + src/include/nodes/execnodes.h | 4 +- src/include/nodes/plannodes.h | 22 +++++++-- src/test/regress/expected/gist.out | 31 +++++++++++++ src/test/regress/sql/gist.sql | 11 +++++ 12 files changed, 123 insertions(+), 66 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix index-only scan plans, take 2. @ 2022-01-03 20:42 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2022-01-03 20:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix index-only scan plans, take 2. Commit 4ace45677 failed to fix the problem fully, because the same issue of attempting to fetch a non-returnable index column can occur when rechecking the indexqual after using a lossy index operator. Moreover, it broke EXPLAIN for such indexquals (which indicates a gap in our test cases :-(). Revert the code changes of 4ace45677 in favor of adding a new field to struct IndexOnlyScan, containing a version of the indexqual that can be executed against the index-returned tuple without using any non-returnable columns. (The restrictions imposed by check_index_only guarantee this is possible, although we may have to recompute indexed expressions.) Support construction of that during setrefs.c processing by marking IndexOnlyScan.indextlist entries as resjunk if they can't be returned, rather than removing them entirely. (We could alternatively require setrefs.c to look up the IndexOptInfo again, but abusing resjunk this way seems like a reasonably safe way to avoid needing to do that.) This solution isn't great from an API-stability standpoint: if there are any extensions out there that build IndexOnlyScan structs directly, they'll be broken in the next minor releases. However, only a very invasive extension would be likely to do such a thing. There's no change in the Path representation, so typical planner extensions shouldn't have a problem. As before, back-patch to all supported branches. Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9c4f38908447c1c6a910e4a16e0644e0ccade204 Modified Files -------------- src/backend/commands/explain.c | 2 +- src/backend/executor/nodeIndexonlyscan.c | 8 ++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/nodes/readfuncs.c | 1 + src/backend/optimizer/plan/createplan.c | 80 +++++++++++--------------------- src/backend/optimizer/plan/setrefs.c | 26 ++++++++++- src/backend/optimizer/plan/subselect.c | 2 + src/include/nodes/execnodes.h | 4 +- src/include/nodes/plannodes.h | 22 +++++++-- src/test/regress/expected/gist.out | 31 +++++++++++++ src/test/regress/sql/gist.sql | 11 +++++ 12 files changed, 123 insertions(+), 66 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-01-03 20:42 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-01-03 20:42 pgsql: Fix index-only scan plans, take 2. Tom Lane <tgl@sss.pgh.pa.us> 2022-01-03 20:42 pgsql: Fix index-only scan plans, take 2. Tom Lane <tgl@sss.pgh.pa.us> 2022-01-03 20:42 pgsql: Fix index-only scan plans, take 2. Tom Lane <tgl@sss.pgh.pa.us> 2022-01-03 20:42 pgsql: Fix index-only scan plans, take 2. Tom Lane <tgl@sss.pgh.pa.us> 2022-01-03 20:42 pgsql: Fix index-only scan plans, take 2. Tom Lane <tgl@sss.pgh.pa.us> 2022-01-03 20:42 pgsql: Fix index-only scan plans, take 2. 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