src\backend\executor\execUtils.c: uint64 PlanStateOperatorMemKB(const PlanState *ps) { Assert(ps); Assert(ps->plan); uint64 result = 0; if (ps->plan->operatorMemKB == 0) { /** * There are some statements that do not go through the resource queue and these * plans dont get decorated with the operatorMemKB. Someday, we should fix resource queues. */ result = work_mem; } else { if (IsA(ps, AggState)) { /* Retrieve all relinquished memory (quota the other node not using) */ result = ps->plan->operatorMemKB + (MemoryAccounting_RequestQuotaIncrease() >> 10); } else result = ps->plan->operatorMemKB; } return result; }