'how to make faster to foreach, search then update more than 100k data?

i have console app for background job. the app will do like this,

  1. get data from database for the location we can call table A(have 100k data) and place to variable
  2. then foreach data of location will search in another table in database we can call table B, and counting how many data they have
  3. then update the count of data in database table A foreach location
  4. after all that is done will update database table c for the summary.

i already make in .net core. and its takes long time for all of the sequence. and my data in table A will add more than 500k.

maybe there is another way to make faster, or using another tech



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source