I have to calculate my products stock cost, so for every product after each buy, i have to recalculate the Weighted Average Cost.
I got a view thats
There already is a aggregate function in C for PostgreSQL available, and it will probably calculate much faster than any solution in SQL:
https://github.com/Kozea/weighted_mean