Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change List backing store code for indexed list to shift in bulk (single statement) #414

Closed
andyjefferson opened this issue Feb 17, 2022 · 1 comment
Milestone

Comments

@andyjefferson
Copy link
Member

Backport from #413 on master branch.

With an indexed list we have an index column. Consequently whenever adding / removing from an indexed list at a position we need to shift all existing elements AFTER that position down to create space.

If we have a list of 10 elements using an index, and we do a List.remove(3) then we get

UPDATE B SET A_ID_OID=NULL, ORDERIDX=-1 WHERE A_ID_OID=1 AND ORDERIDX=3
UPDATE B SET ORDERIDX = ORDERIDX + -1 WHERE A_ID_OID=1 AND ORDERIDX=4
UPDATE B SET ORDERIDX = ORDERIDX + -1 WHERE A_ID_OID=1 AND ORDERIDX=5
UPDATE B SET ORDERIDX = ORDERIDX + -1 WHERE A_ID_OID=1 AND ORDERIDX=6
UPDATE B SET ORDERIDX = ORDERIDX + -1 WHERE A_ID_OID=1 AND ORDERIDX=7
UPDATE B SET ORDERIDX = ORDERIDX + -1 WHERE A_ID_OID=1 AND ORDERIDX=8
UPDATE B SET ORDERIDX = ORDERIDX + -1 WHERE A_ID_OID=1 AND ORDERIDX=9

whereas we ought to do

UPDATE B SET A_ID_OID=NULL, ORDERIDX=-1 WHERE A_ID_OID=1 AND ORDERIDX=3
UPDATE B SET ORDERIDX = ORDERIDX + -1 WHERE A_ID_OID=1 AND ORDERIDX>3
@chrisco484
Copy link
Contributor

chrisco484 commented Apr 18, 2023

It looks like I've found a bug related to this optimization - testcase is available in issue #464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants