how to call lo_unlink(lo) in batches
Only solution so far is via bash script:
#!/bin/bash
user=myuser
host=127.0.0.1
database=mydb
batch_size=10000

elements=$( psql -X -A -U $user -h $host -d $database -t -c &quot;SELECT COUNT (*) FROM vacuum_l where deleted = false&quot; )
echo &quot;los to unlink:&quot;
echo $elements
echo
num_batches=$((elements / batch_size))
num_batches=$((num_batches + 1))
echo &quot;Batches:&quot;
echo $num_batches
echo
for ((i = 1; i &lt;= $num_batches; i++)); do
    echo &quot;Batch &quot;$i
    psql -U $user -h $host -d $database -c &quot;UPDATE vacuum_l SET deleted = true, lo = lo_unlink(lo) WHERE lo IN (SELECT lo FROM vacuum_l where deleted=false limit $batch_size )&quot;
done