Re: Add ExprState hashing for GROUP BY and hashed SubPlans

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add ExprState hashing for GROUP BY and hashed SubPlans
Date: 2024-11-05 20:38:09
Message-ID: CAApHDvq7ZLCaaXk04O_hb0VQ2f3feF_pRoEfuYMTw8rUrARsaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 2 Nov 2024 at 22:13, Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
> Okay, I passed through the code. It looks good. Hashing expressions are
> too simple to give notably impressive results, but it is a step in the
> right direction.
> I found only one minor issue: an outdated comment (see attachment).

Thanks for looking. I ended up doing a bit more work on that comment.
See attached.

I was performing some final benchmarks on this and found that there's
a small performance regression for hashed subplans.

The test case is:
create table t1 (a int);
insert into t1 select a from generate_series(1,100000)a;

select * from t1 where a not in(select a from t1);

With my Zen4 laptop I get:

gcc:
master tps = 58.0375255
v5-0001 tps = 56.11840762

clang:
master tps = 58.72993378
v5-0001 tps = 53.39965968

Zen2 3990x
gcc:
master tps = 34.30392818
v5-0001 tps = 33.22067202

clang:
master tps = 34.0497471
v5-0001 tps = 33.34801254

That's the average over 50 runs starting and stopping the server on
each 10 second run.

I'm still thinking about what to do about this. In the meantime, I'm
not going to commit it.

> Also, to make a hash calculation as fast as possible, should we add the
> call of murmurhash32 as an optional step of ExprState in the
> ExecBuildHash32FromAttrs?

I wrote enough of this patch to test the performance. It does not
help. See attached 0002.

David

Attachment Content-Type Size
v5-0001-Use-ExprStates-for-hashing-in-GROUP-BY-and-SubPla.patch text/plain 20.3 KB
v5-0002-Support-murmur32-hashing-of-the-final-ExprState-h.patch.txt text/plain 7.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-11-05 21:06:05 Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Previous Message Jelte Fennema-Nio 2024-11-05 20:21:35 Re: Interrupts vs signals