cloudberry
cloudberry copied to clipboard
[Bug] ORCA generates wrong plan for select-for-update statement.
Apache Cloudberry version
No response
What happened
when set optimizer to on, plan for select-for-update statement is not correct because LockRows is lacked.
postgres=# set optimizer to on;
SET
postgres=# explain select * from test for update;
QUERY PLAN
------------------------------------------------------------------------------
Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..431.00 rows=1 width=4)
-> Seq Scan on test (cost=0.00..431.00 rows=1 width=4)
Optimizer: GPORCA
(3 rows)
postgres=# set optimizer to off;
SET
postgres=# explain select * from test for update;
QUERY PLAN
------------------------------------------------------------------------------------
Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..2457.50 rows=96300 width=10)
-> LockRows (cost=0.00..1013.00 rows=48150 width=10)
-> Seq Scan on test (cost=0.00..531.50 rows=48150 width=10)
Optimizer: Postgres query optimizer
(4 rows)
What you think should happen instead
No response
How to reproduce
set optimizer to on;
explain select * from test for update;
Operating System
centos
Anything else
No response
Are you willing to submit PR?
- [ ] Yes, I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct.
Hi, @HuSen8891 welcome!🎊 Thanks for taking the time to point this out.🙌