public inbox for [email protected]  
help / color / mirror / Atom feed
From: =?utf-8?B?QW5keSBIdWFuZw==?= <[email protected]>
To: =?utf-8?B?RHVyZ2FtYWhlc2ggTWFubmU=?= <[email protected]>
To: =?utf-8?B?cGdzcWwtZ2VuZXJhbA==?= <[email protected]>
Subject: Re: Regarding query optimisation (select for update)
Date: Tue, 15 Jul 2025 21:05:52 +0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAJCZko+fiU+=NSEGY7d7YMpFxg_jANpiO-LU6ur+yqRc_Ej6eQ@mail.gmail.com>
References: <CAJCZko+fiU+=NSEGY7d7YMpFxg_jANpiO-LU6ur+yqRc_Ej6eQ@mail.gmail.com>

Can you try like: ORDER BY betid desc



---Original---
From: "Durgamahesh Manne"<[email protected]&gt;
Date: Tue, Jul 15, 2025 18:10 PM
To: "pgsql-general"<[email protected]&gt;;
Subject: Regarding query optimisation (select for update)


Hi Team,

We are facing issues&nbsp;with slow running query&nbsp;
&nbsp; &nbsp;SELECT betid, versionid, betdata, processed, messagetime, createdat, updatedat FROM praermabetdata where processed = 'false' ORDER BY betid, versionid LIMIT 200 OFFSET 0 FOR UPDATE;&nbsp;&nbsp;


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
&nbsp;Limit &nbsp;(cost=0.28..1.89 rows=1 width=78)
&nbsp; &nbsp;-&gt; &nbsp;LockRows &nbsp;(cost=0.28..1.89 rows=1 width=78)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; &nbsp;Index Scan using idx_praermabetdata_processed_betid_versionid on praermabetdata &nbsp;(cost=0.28..1.88 rows=1 width=78)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Index Cond: (processed = false)







Do we have any alternative way to improve the performance?
Sometimes processed column use true as well as false&nbsp;


Regards,
Durga Mahesh&nbsp;

Attachments:

  [application/octet-stream] [email protected] (18.0K, [email protected])
  download

view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Regarding query optimisation (select for update)
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox