I wrote:
> I've not got to the bottom of it yet either, but I notice that if you
> replace the VALUES thingy with a plain table, the bug goes away:
Oh, scratch that --- if you "ANALYZE q1", it goes right back to the
bogus plan. So knowing that q1 is small is part of the triggering
condition for picking the bogus plan, but VALUES per se isn't.
regards, tom lane