Hi,

Currently for hash joins, only a hash table that fits in memory (one batch) is reused on each rescan, spilled hash tables need to be rebuilt on each iteration.

The motivation comes from recursive CTEs where the Hash is on a base table (mostly graph queries), rebuilding it on every iteration hurts quite a bit, and I see very nice improvements when we avoid the rebuilds.

Surely it can get dirty very quickly, because it must end up touching EXEC_FLAG_REWIND / rescan infra, so other rescan cases can benefit too (though I'm not sure how valuable they can be in practice, what i know is that they are uncommon, hence why its like this today).

Since other cases are rarer (e.g: Nested Loops) than graph queries with a decent fan-out, one could argue that user should just raise hash_mem_multiplier.

It does add some complexity and slightly unusual executor work (like retaining batch 0, etc.). Would it be wise to pursue this?

I don't have a patch worth reviewing yet, if it makes sense doing, i'll spend more time on it and follow up with something.

Regards,
Ayoub Kazar



Reply via email to