Is a clearer memory lifespan for outerTuple and innerTuple useful?

Поиск
Список
Период
Сортировка
От Andy Fan
Тема Is a clearer memory lifespan for outerTuple and innerTuple useful?
Дата
Msg-id 87edfnc3nh.fsf@163.com
обсуждение исходный текст
Ответы Re: Is a clearer memory lifespan for outerTuple and innerTuple useful?  (Andy Fan <zhihuifan1213@163.com>)
Список pgsql-hackers
Hi,

When I am working on "shared detoast value"[0], where I want to avoid
detoast the same datum over and over again, I have to decide which
memory context should be used to hold the detoast value. later I 
found I have to use different MemoryContexts for the OuterTuple and
innerTuple since OuterTuple usually have a longer lifespan.

I found the following code in nodeMergeJoin.c which has pretty similar
situation, just that it uses ExprContext rather than MemoryContext.

MergeJoinState *
ExecInitMergeJoin(MergeJoin *node, EState *estate, int eflags)

    /*
     * we need two additional econtexts in which we can compute the join
     * expressions from the left and right input tuples.  The node's regular
     * econtext won't do because it gets reset too often.
     */
    mergestate->mj_OuterEContext = CreateExprContext(estate);
    mergestate->mj_InnerEContext = CreateExprContext(estate);

IIUC, we needs a MemoryContext rather than ExprContext in fact. In the
attachment, I just use two MemoryContext instead of the two ExprContexts
which should be less memory and more precise semantics, and works
fine. shall we go in this direction?  I attached the 2 MemoryContext in
JoinState rather than MergeJoinState, which is for the "shared detoast
value"[0] more or less.  

[0] https://www.postgresql.org/message-id/87ttoyihgm.fsf@163.com


-- 
Best Regards
Andy Fan

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: wenhui qiu
Дата:
Сообщение: Support "Right Semi Join" plan shapes
Следующее
От: Andy Fan
Дата:
Сообщение: Re: Is a clearer memory lifespan for outerTuple and innerTuple useful?