On Sun, 11 Apr 2021 at 10:38, Tomas Vondra <tomas.von...@enterprisedb.com> wrote: > I wonder what's the relationship between the length of the IN list and > the minimum number of rows needed for the hash to start winning.
I made the attached spreadsheet which demonstrates the crossover point using the costs that I coded into cost_qual_eval_walker(). It basically shows, for large arrays, that there are fairly significant benefits to hashing for just 2 lookups and not hashing only just wins for 1 lookup. However, the cost model does not account for allocating memory for the hash table, which is far from free. You can adjust the number of items in the IN clause by changing the value in cell B1. The values in B2 and B3 are what I saw the planner set when I tested with both INT and TEXT types. David
cost_comparison_hashed_vs_non-hashed_saops.ods
Description: application/vnd.oasis.opendocument.spreadsheet