Question: Edit : I need the program to do computational faster, the update process is needed to be real time (calculating 100.000 to 200.000 records for about 0-5 seconds), this process will be doing in multi threading (about 2-8 thread)

---

I will create program that will update data in database. The update process will be triggered if I do insert data in table. The update process will computational costly. This is the idea of my update process :

1. I will have 3 tables (A,B,C) and each of it will have data aroud 100.000-200.000 records
2. I will have table D to save table A, B, C record count
3. I will have table E to save table A, B, C, D calculation, the calculation including multiplication, division and log base 2
4. I will insert data to table A, B, C and after that data in table D and E must be updated
5. This process can be repeated 3-5 times in every update

Which one is computationally faster, doing update programmatically or using trigger?

Answer: 
Better to go with `TRIGGERS` and keep this complexity on DB side. This will help you in keeping your code clean. If you are going to do `INSERT` from different files then you may need to rewrite `UPDATE` logic in all those files.

And if in future you need to change the after insert logic then you just need to update your trigger instead of updating the code.
> 
> I will have 3 tables (A,B,C) and each of it will have data aroud
>  100.000-200.000 records
> 
> 
> 

This is a trivially small database.

```
I will have table D to save table A, B, C record count

```

Are you keeping a history of records in each on a particular datetime? That's the only reason to do this.

```
I will have table E to save table A, B, C, D calculation, the calculation including multiplication, division and log base 2

```

Easy stuff.

```
I will insert data to table A, B, C and after that data in table D and E must be updated

```

Making all of this a single unit of work is the important thing. I hope you're making them a transaction.

This process can be repeated 3-5 times in every update Which one is faster, doing update programmatically or using trigger?

I would think database - stored procedure and trigger first. Especially if there are a lot of UPDATEs.

Are the three sources of data A, B, and C independent? If I INSERT into A, do I execute the calculations for D and E? Likewise for B and C? Could you potentially have a great deal of traffic if all three have records INSERTed in a short period of time?