Nate on Nostr: Again, I could very well be reading this wrong, but the joins dont look necassary to ...
Again, I could very well be reading this wrong, but the joins dont look necassary to me, it could look something like this
SELECT *
FROM nostr_events ne
WHERE (kind IN ($1, $2) AND pubkey IN ($3))
AND EXISTS (
SELECT 1
FROM nostr_tags tag0
WHERE tag0.event_id = ne.id
AND tag0.name = $4
AND tag0.value IN ($5, $6)
))
(this isnt directly taken from your query below, this is just an example)
This is also why i recommended the use of the composite index (event_id, name, value), which I would image would give a huge performance boost on that EXISTS check, but without being able to test it (and make sure it returns the correct results) I could be talking out of my ass
Published at
2024-07-02 05:30:25Event JSON
{
"id": "3f9c648436b8de05151b5cfd8b49558604439a0c651b77d980415e124af971c9",
"pubkey": "eed6badd6a63b86c57e46874bb35eed75561417b99beb7044ec29f850501f704",
"created_at": 1719898225,
"kind": 1,
"tags": [
[
"p",
"0461fcbecc4c3374439932d6b8f11269ccdb7cc973ad7a50ae362db135a474dd"
],
[
"p",
"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"
],
[
"e",
"ac7d4f14106c6e558a79c4685b26a5dec43a39dfec046e2b43aadb6b534be829",
"wss://nostr.fmt.wiz.biz/",
"root"
],
[
"e",
"44ecf808dea576c3587accd7fc4cfd5d112e404d0a80510ec2f116c4a393c04f",
"wss://nostr.fmt.wiz.biz/",
"reply"
]
],
"content": "Again, I could very well be reading this wrong, but the joins dont look necassary to me, it could look something like this\n\nSELECT *\nFROM nostr_events ne\nWHERE (kind IN ($1, $2) AND pubkey IN ($3)) \n\tAND EXISTS (\n SELECT 1\n FROM nostr_tags tag0\n WHERE tag0.event_id = ne.id\n AND tag0.name = $4\n AND tag0.value IN ($5, $6)\n ))\n\n(this isnt directly taken from your query below, this is just an example)\n\nThis is also why i recommended the use of the composite index (event_id, name, value), which I would image would give a huge performance boost on that EXISTS check, but without being able to test it (and make sure it returns the correct results) I could be talking out of my ass",
"sig": "f66c5ff1dc7a09b33d5aed9211f5bd7a85f9f1ce946fb13e96a338ab6c19595c05904db48b730a488796e24c04b0c237141a1ccb49f88163af969ddbdb8ccc64"
}