pgsql: nbtree: Avoid allocating _bt_search stack.
pgsql: nbtree: Avoid allocating _bt_search stack.
От:
Peter Geoghegan <pg@bowt.ie>
Дата:
nbtree: Avoid allocating _bt_search stack. Avoid allocating memory for an nbtree descent stack during index scans. We only require a descent stack during inserts, when it is used to determine where to insert a new pivot tuple/downlink into the target leaf page's parent page in the event of a page split. (Page deletion's first phase also performs a _bt_search that requires a descent stack.) This optimization improves performance by minimizing palloc churn. It speeds up index scans that call _bt_search frequently/descend the index many times, especially when the cost of scanning the index dominates (e.g., with index-only skip scans). Testing has shown that the underlying issue causes performance problems for an upcoming patch that will replace btgettuple with a new btgetbatch interface to enable I/O prefetching. Author: Peter Geoghegan Reviewed-By: Tomas Vondra Discussion: https://postgr.es/m/CAH2-Wzmy7NMba9k8m_VZ-XNDZJEUQBU8TeLEeL960-rAKb-+tQ@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/d071e1cfec23505e0f55f06988c0144f16235586 Modified Files -------------- contrib/amcheck/verify_nbtree.c | 4 +--- src/backend/access/nbtree/nbtinsert.c | 19 ++++++++++++++++++- src/backend/access/nbtree/nbtpage.c | 2 +- src/backend/access/nbtree/nbtsearch.c | 35 ++++++++++++++++++----------------- src/backend/access/nbtree/nbtutils.c | 16 ---------------- src/include/access/nbtree.h | 3 +-- 6 files changed, 39 insertions(+), 40 deletions(-)