title: Batch delete in Postgres using a cursor
body: <p>I am new to Postgres and have a task to delete records from a live table that was created unpartitioned. Now my head is towards creating a cursor to delete the records in a controlled way.</p>
  
  <p>The steps I have in my head:</p>
  
  <ul>
  <li>declare a cursor, open it </li>
  <li>fetch records into the cursor where there will be a filter on date</li>
  <li>pass controlled records say 5000/transaction to delete statement</li>
  <li>loop until the initial fetch is completed </li>
  <li>exit loop and close the cursor</li>
  </ul>
  
  <p>Would that make sense?</p>