Re: weird hash plan cost, starting with pg10 - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: weird hash plan cost, starting with pg10
Date
Msg-id 20200427161823.GY28974@telsasoft.com
Whole thread Raw
In response to Re: weird hash plan cost, starting with pg10  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: weird hash plan cost, starting with pg10  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Apr 10, 2020 at 04:11:27PM -0400, Tom Lane wrote:
> I'm not sure it's worth any risk though.  A much simpler
> fix is to make sure we clear the dangling hashtable pointer, as in
> 0002 below (a simplified form of Konstantin's patch).  The net
> effect of that is that in the case where a hash table is destroyed
> and never rebuilt, EXPLAIN ANALYZE would report no hash stats,
> rather than possibly-garbage stats like it does today.  That's
> probably good enough, because it should be an uncommon corner case.
> 
> Thoughts?

Checking if you're planning to backpatch this ?

> diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
> index c901a80..9e28ddd 100644
> --- a/src/backend/executor/nodeHashjoin.c
> +++ b/src/backend/executor/nodeHashjoin.c
> @@ -1336,6 +1336,12 @@ ExecReScanHashJoin(HashJoinState *node)
>          else
>          {
>              /* must destroy and rebuild hash table */
> +            HashState  *hashNode = castNode(HashState, innerPlanState(node));
> +
> +            /* for safety, be sure to clear child plan node's pointer too */
> +            Assert(hashNode->hashtable == node->hj_HashTable);
> +            hashNode->hashtable = NULL;
> +
>              ExecHashTableDestroy(node->hj_HashTable);
>              node->hj_HashTable = NULL;
>              node->hj_JoinState = HJ_BUILD_HASHTABLE;


-- 
Justin



pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: doc review for v13
Next
From: Robert Haas
Date:
Subject: Re: +(pg_lsn, int8) and -(pg_lsn, int8) operators