My queries get very slow when I add a limit 1.
I have a table object_values with timestamped values for objects:
timestam
I started having similar symptoms on an update-heavy table, and what was needed in my case was
analyze $table_name;
In this case the statistics needed to be refreshed, which then fixed the slow query plans that were occurring.
Supporting docs: https://www.postgresql.org/docs/current/sql-analyze.html