Why do you create a new topic? Normally topics have a long life span. It would be possible for remote devices to update the database but then it becomes a management and security issue and doesn't resolve the bottleneck problem, it just moves it elsewhere, but limits your options to address it. The whole point of a publish and subscribe approach is to create boundaries as well as manage throughput. I did, however, suggest earlier that one Pi doing everything might be a bottleneck. I'd suggest stop creating new topics as that's an overhead you don't need. Another Pi, just as a listener to a topic, could be used solely to do database updates. If that proves a bottleneck you can have multiple listeners to a topic until the database itself becomes the bottleneck.