-> Seq Scan on contract co (cost=0.00..336.12 rows=7212 width=8) (actual time=0.005..2.835 rows=7198 loops=1)
Planning time: 0.325 ms
Execution time: 492.686 ms
It looks like unanalyzed data - the system thinking so there are not any data. Try to run ANALYZE more frequently or after any significant change of table