Merge pull request #4528 from dongwonmoon/codex/session-activity-exists

Use correlated EXISTS for PostgreSQL session activity data
This commit is contained in:
Mike Cao authored and GitHub committed 2026-09-10 22:49:02 -07:00
commit 2a5ef9d9e8
1 file changed
+6 -5
@@ -31,11 +31,12 @@ async function relationalQuery(websiteId: string, sessionIds: string[], filters:
event_name as "eventName",
visit_id as "visitId",
hostname,
event_id IN (select website_event_id
from event_data
where website_id = {{websiteId::uuid}}
and created_at between {{startDate}} and {{endDate}}) AS "hasData"
from website_event
EXISTS (select 1
from event_data d
where d.website_event_id = e.event_id
and d.website_id = {{websiteId::uuid}}
and d.created_at between {{startDate}} and {{endDate}}) AS "hasData"
from website_event e
where website_id = {{websiteId::uuid}}
and session_id = any({{sessionIds}}::uuid[])
and event_type != ${EVENT_TYPE.performance}