Oddbean new post about | logout
 btw there's no limit on any of these, and they need to be returned in reverse-chronological order. It results in this monster query with 6 joins and 55 parameters. Christ.

select * from (select "nostr_events".* from "nostr_events" where "kind" in ($1, $2) and "pubkey" in ($3) limit $4) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" where "kind" in ($5, $6, $7) and "pubkey" in ($8, $9)) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" inner join "nostr_tags" as "tag0" on "tag0"."event_id" = "nostr_events"."id" where "kind" in ($10) and "tag0"."name" = $11 and "tag0"."value" in ($12, $13) order by "created_at" desc) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" where "kind" in ($14, $15, $16) and "pubkey" in ($17)) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" inner join "nostr_tags" as "tag0" on "tag0"."event_id" = "nostr_events"."id" where "kind" in ($18) and "tag0"."name" = $19 and "tag0"."value" in ($20) order by "created_at" desc) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" where "kind" in ($21, $22, $23) and "pubkey" in ($24, $25, $26)) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" inner join "nostr_tags" as "tag0" on "tag0"."event_id" = "nostr_events"."id" where "kind" in ($27) and "tag0"."name" = $28 and "tag0"."value" in ($29, $30, $31) order by "created_at" desc) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" where "kind" in ($32, $33, $34) and "pubkey" in ($35)) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" inner join "nostr_tags" as "tag0" on "tag0"."event_id" = "nostr_events"."id" where "kind" in ($36) and "tag0"."name" = $37 and "tag0"."value" in ($38) order by "created_at" desc) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" where "kind" in ($39, $40, $41) and "pubkey" in ($42, $43)) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" inner join "nostr_tags" as "tag0" on "tag0"."event_id" = "nostr_events"."id" where "kind" in ($44) and "tag0"."name" = $45 and "tag0"."value" in ($46, $47) order by "created_at" desc) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" where "kind" in ($48, $49, $50) and "pubkey" in ($51)) as "nostr_events" union all select * from (select "nostr_events".* from "nostr_events" inner join "nostr_tags" as "tag0" on "tag0"."event_id" = "nostr_events"."id" where "kind" in ($52) and "tag0"."name" = $53 and "tag0"."value" in ($54) order by "created_at" desc) as "nostr_events" limit $55