David Teran <david.teran@cluster9.com> writes:
> explain result from second query:
> Seq Scan on "KEY_VALUE_META_DATA" t0 (cost=0.00..2671.16 rows=931 width
> =1068) (actual time=122.669..172.179 rows=25 loops=1)
> Filter: (("ID_VALUE" = 21094) OR ("ID_VALUE" = 21103))
The problem is evidently that the row estimate is so far off (931
estimate vs 25 actual). Have you done ANALYZE or VACUUM ANALYZE
on this table recently? If you have, I'd be interested to see the
pg_stats row for ID_VALUE. It might be that you need to increase
the statistics target for this table.
regards, tom lane