Can you try like: ORDER BY betid desc
---Original--- From: "Durgamahesh Manne"<maheshpostgr...@gmail.com> Date: Tue, Jul 15, 2025 18:10 PM To: "pgsql-general"<pgsql-general@lists.postgresql.org>; Subject: Regarding query optimisation (select for update) Hi Team, We are facing issues with slow running query SELECT betid, versionid, betdata, processed, messagetime, createdat, updatedat FROM praermabetdata where processed = 'false' ORDER BY betid, versionid LIMIT 200 OFFSET 0 FOR UPDATE; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.28..1.89 rows=1 width=78) -> LockRows (cost=0.28..1.89 rows=1 width=78) -> Index Scan using idx_praermabetdata_processed_betid_versionid on praermabetdata (cost=0.28..1.88 rows=1 width=78) Index Cond: (processed = false) Do we have any alternative way to improve the performance? Sometimes processed column use true as well as false Regards, Durga Mahesh
0D59E1CB@A7AE4F48.3052766800000000.png
Description: Binary data