Nostr is a relay sytem. Its not a storage system. Its not a database. It is ephemeral by design. It is not designed for complex queries. Almost all of nostr's probems can be solved by realizing this simple reality. Simply let nostr be nostr, and you are golden.