MDL-66327 pgsql DML: Update get_records_sql to consume less memory