Just tried to insert records in batches with batch size set to 100 and it worked. Now, I am going to increase the batch size to 200, 500 etc. and see what could be the maximum batch size.
for (let i = 0; i < cacheusers.length; i += 100) {
await AppDataSource.createQueryBuilder()
.insert()
.into(UsersCacheORM)
.values(cacheusers.slice(i, i + 100))
.execute();
}