Full index scan planned for tables with small number of rows #56661
Labels
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
O-community
Originated from the community
X-blathers-triaged
blathers was able to find an owner
Describe the problem
A transaction retry is being fired when two transactions, each with inserts on a table that has a FK reference for tables with a small amount of records. It seems very similar to this issue: #41701. I believe the hash join / full scan on the constraint is blocking the other insert transaction. Below are my steps to reproduce the issue:
To Reproduce
Recreation steps
-- Create two terminal session and alternate between each step of the transaction to recreate
-- The retry occurs in terminal 1 when we insert into ch (2,2).
-- The first two inserts into p work.
-- The insert into ch waits in terminal 1
-- The insert into ch completes in terminal 2 which causes the ch insert in terminal 1 to retry.
-- Do this in one terminal
create table p (id int primary key);
create table ch (id int primary key, p_id int not null references p);
create index idx_ch_p_id on ch(p_id);
begin transaction;
insert into p values (1);
insert into ch values (1,1);
commit;
-- Do this in another terminal
begin transaction;
insert into p values (2);
insert into ch values (2,2);
commit;
-- Cleanup
drop table ch;
drop table p;
Terminal 1
Terminal 2
If applicable, add screenshots to help explain your problem.
Environment:
gz#7820
The text was updated successfully, but these errors were encountered: