title: Optimize Postgres Query
body: <p>I noticed following query in my code and want to check if this can be optimized.</p>
  
  <pre><code>UPDATE table as T1 SET C1=? 
    FROM 
      (SELECT C2, C3, C4 
          FROM table 
          WHERE C1=? and current_timestamp &gt;= C5 
          ORDER BY C5 limit ? FOR UPDATE
      ) AS T2 
  WHERE T1.C2 = T2.C2 AND T1.C3 = T2.C3 AND T1.C4 = T2.C4
  RETURNING *;
  </code></pre>
  
  <p>index on C2, C3</p>
  
  <p>partitioned on C5</p>
  
  <p>table :</p>
  
  <p>C1, C2, C3 - varchar<br/>
  C4, C5 - timestamp</p>