On Sat, Jun 18, 2016 at 5:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> . In 9.x, that's broken and it falls back to
> get_typavgwidth's default guess of 32 bytes. If what you've actually
> got is, say, varchar(255) and most of the entries actually approach
> that length, this could result in a drastic underestimate, possibly
> leading to OOM from hash table growth.
This seems more likely to result in the converse. 32 bytes is enough
distinct values I imagine it's going to avoid a hash join. (and In any
case if you have a varchar(n) where n>32 then it's probably a bad bet
to assume n gives much information about the typical length of the
strings). On the other hand if what you've actually got is a
varchar(1) or something like that then indeed a hash join might have
been a good choice.
--
greg