Ayo <ayo@xxxxxxxxxx> writes: > On 2021-02-23, Tom Lane wrote: >> The slow query isn't using the chars_pkey1 index, which makes one >> wonder if you have a corresponding index in the custom-type case, > The index exists and is usable in the custom-type case: Hmm. The next most likely theory seems to be something wrong with cost estimation, causing the planner to avoid the nestloop-with- inner-indexscan plan even though it would work. Have you tried "enable_seqscan = off" (and maybe also disable merge and hash joins) to see if you can force choice of that plan? regards, tom lane