We reduced the cost of building Mastodon at Twitter-scale by 100x 3 years ago
This is a problem that is very similar to the one solved by Differential Data Flow and implemented by https://github.com/MaterializeInc/materialize
Have you considered using that?