I just looked this email from postgress sql site and wanted to
ask you a question. I would be obliged if you could help me understand
the duplicate key insertion behaviour correctly in Post gress SQL.
The question is related to Btree [Leman and Yao] implementation
When handling duplicate keys
a) Is the key really a duplicate key or TID makes it unique in whole of
the index ?
a) When inserting data into the BTREE in case of leaf nodes we move
to the right in a random behaviourand check if we need to split or
What does the first movedright mean in the code below.
/* Now we are on the right page, so find the insert position. If
* moved right at all, we know we should insert at the start of
* page, else must find the position by searching.
newitemoff = P_FIRSTDATAKEY(lpageop);
newitemoff = _bt_binsrch(rel, buf, keysz, scankey, false);
b) Once we move right on the leaf , How do we adjust
the parent where to insert once we move right on the
child in case of duplicates.. Does the non leaf contain multiple
duplicate keys as well or is it that the leaf nodes contain multiple
values for the same key .
Can you please help me understand this,
Thanks and appreciate your time.