A small performance bug in BTree Infrastructure

From: "Gokulakannan Somasundaram" <gokul007(at)gmail(dot)com>
To: "pgsql-hackers list" <pgsql-hackers(at)postgresql(dot)org>
Subject: A small performance bug in BTree Infrastructure
Date: 2008-10-23 15:01:29
Message-ID: 9362e74e0810230801t41e7df7ax10745c75df88f6cf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All,
BTree Insert requires a data-structure called BTStack to report the
page splits that have happened in the leaf pages to non-leaf pages upwards.
It basically goes back and updates those non-leaf pages. But this will never
happen in a search operation. You never need to climb upwards for a Select
statement. Actually we can clearly see that in the _bt_first function, as
soon as we complete calling _bt_search, we call _bt_freestack to free it. So
unnecessarily a BTStack structure is getting formed and deleted.
Inside _bt_search function, if we just add a if condition to check
whether access is for BT_READ, then we can avoid the creation of stack and
also remove the _bt_freestack in the _bt_first function. I just implemented
the change and tested it and i am not seeing any performance difference(as
expected).

Still i thought of reporting it, so that whoever is working on it,
can incorporate this change also.

Thanks,
Gokul.

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-10-23 15:04:43 Re: Unicode escapes in literals
Previous Message Zdenek Kotala 2008-10-23 14:50:24 Any reason to have heap_(de)formtuple?