Why Nostr? What is Njump?
2023-01-25 22:00:44
in reply to

aaron on Nostr: Similar. I've been thinking about rewriting queries like this to consolidate them ...

Similar.

I've been thinking about rewriting queries like this to consolidate them (and be somewhat more efficient) when they can be.

This works with "authors" because no two events can match the same author, but it doesn't work for other queries.

For example, [..., {"#p": ["a", "b"]] and [..., {"#p": ["a"]}, {"#p": ["b"]}] are not quite the same.

you are probably getting away with UNION in these cases and letting db engine do the de-duplicating for you.

But once you implement cursor/"pagination" of queries, leaning on UNION for deduplication won't work.

I'm doing pagination/cursor-based query results now, which means you might get duplicate events in some cases for a separated "#p" query like that.

However, once I implement query rewriting this will be partially fixed by rewriting [..., {"#p": ["a"]}, {"#p": ["b"]}] to [..., {"#p": ["a", "b"]], which will be more efficient and naturally produce non-duplicate results.

For query filters that can't be consolidated -- e.g., [..., {"#p": ["a"]}, {"#p": ["b"], "authors": ["dead"]}}] -- deduplication is kinda tricky and not ideal, so will have to figure that out at some point or live with it.


Author Public Key
npub14lu6nuqh7v4jazmqw49yzqkmnkw0nletjeuqfdgwqurcp2j9ex5qz37m8m