The two elixir snippets are pretty much all there is and comes from the very basic documentation examples. There were a couple of other unresolved concerns on the internet about this exact problem related to the fetch override and duplicate queries being called:
The rest of the non-elixir stuff below the presence.ex code is just my custom IO.inspect
to show when a query is run and what the query looks like (to show which ids are trying to be fetched). I added that there just to show that there are indeed 4 queries being called for just one person joining the room (two queries are exact duplicates), and 2 queries for one person leaving the room.
The problem is, I don’t even know why or where this many queries are being called. I think it’s an unnecessary waste of database resources. It might even be a bug.