8000 Re-use free space on index pages with duplicates. · postgrespro/postgres_cluster@1ecb43a · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

< 8000 /div>
Appearance settings

Commit 1ecb43a

Browse files
committed
Re-use free space on index pages with duplicates.
1 parent 10d6d41 commit 1ecb43a

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

src/backend/access/nbtree/nbtinsert.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.49 1999/07/19 07:07:19 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.50 1999/08/09 01:39:19 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -392,17 +392,18 @@ _bt_insertonpg(Relation rel,
392392
bool is_root = lpageop->btpo_flags & BTP_ROOT;
393393

394394
/*
395-
* If we have to split leaf page in the chain of duplicates by new
396-
* duplicate then we try to look at our right sibling first.
395+
* Instead of splitting leaf page in the chain of duplicates
396+
* by new duplicate, insert it into some right page.
397397
*/
398398
if ((lpageop->btpo_flags & BTP_CHAIN) &&
399399
(lpageop->btpo_flags & BTP_LEAF) && keys_equal)
400400
{
401-
bool use_left = true;
402-
403401
rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE);
404402
rpage = BufferGetPage(rbuf);
405403
rpageop = (BTPageOpaque) PageGetSpecialPointer(rpage);
404+
/*
405+
* some checks
406+
*/
406407
if (!P_RIGHTMOST(rpageop)) /* non-rightmost page */
407408
{ /* If we have the same hikey here then
408409
* it's yet another page in chain. */
@@ -418,32 +419,20 @@ _bt_insertonpg(Relation rel,
418419
BTGreaterStrategyNumber))
419420
elog(FATAL, "btree: hikey is out of order");
420421
else if (rpageop->btpo_flags & BTP_CHAIN)
421-
422422
/*
423423
* If hikey > scankey then it's last page in chain and
424424
* BTP_CHAIN must be OFF
425425
*/
426426
elog(FATAL, "btree: lost last page in the chain of duplicates");
427-
428-
/* if there is room here then we use this page. */
429-
if (PageGetFreeSpace(rpage) > itemsz)
430-
use_left = false;
431427
}
432428
else
433429
/* rightmost page */
434430
{
435431
Assert(!(rpageop->btpo_flags & BTP_CHAIN));
436-
/* if there is room here then we use this page. */
437-
if (PageGetFreeSpace(rpage) > itemsz)
438-
use_left = false;
439-
}
440-
if (!use_left) /* insert on the right page */
441-
{
442-
_bt_relbuf(rel, buf, BT_WRITE);
443-
return (_bt_insertonpg(rel, rbuf, stack, keysz,
444-
scankey, btitem, afteritem));
445432
}
446-
_bt_relbuf(rel, rbuf, BT_WRITE);
433+
_bt_relbuf(rel, buf, BT_WRITE);
434+
return (_bt_insertonpg(rel, rbuf, stack, keysz,
435+
scankey, btitem, afteritem));
447436
}
448437

449438
/*

0 commit comments

Comments
 (0)
0