The reduced database example has the same problem in EXPLAIN ANALYZE as
production one, here:
Seq Scan on bar (cost=0.00..393.07 rows=1 width=4) (actual
time=0.098..3.561 rows=24 loops=1)
That's why I posted the smallest dataset I could reproduce the problem with.
Rodrigo E. De León Plicet wrote:
>
> Then provide actual DDL plus the production EXPLAIN ANALYZE output and
> post it, maybe one of the Postgres gurus can help.
>
> Good luck.