Re: Add ExprState hashing for GROUP BY and hashed SubPlans

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: Andrei Lepikhov <lepihov@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-29T09:47:22Z
Lists: pgsql-hackers

Attachments

On Mon, 28 Oct 2024 at 21:51, Andrei Lepikhov <lepihov@gmail.com> wrote:
> Having remembered that SQL Server uses lightweight threads to execute
> massive hash and aggregate operations in parallel, I think this patch is
> promising. Unfortunately, it causes SEGFAULT on 'make check'.

Thanks for having a look. The crash is because I'd not quite gotten
around to adjusting this to account for the changes made in 9ca67658d
yet. Without adjustment, the ExprState evaluation code would be
looking at an uninitialised location to store the intermediate hash
value.

I've attached an updated patch with a few other fixes. Whilr checking
this tonight, noticed that master does not use
SubPlanState.tab_eq_funcs for anything. I resisted removing that in
this patch. Perhaps a follow-on patch can remove that. I suspect it's
not been used for a long time now, but I didn't do the archaeology
work to find out.

David

Commits

  1. Use ExprStates for hashing in GROUP BY and SubPlans

  2. Speedup Hash Joins with dedicated functions for ExprState hashing

  3. Remove unused field from SubPlanState struct