Pager usage is off. BEGIN set_config ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ {"sub": "00000000-0000-4000-8000-000300000001", "account_id": "00000000-0000-4000-8000-003000000001", "account_type": "INSTITUTION", "institution_id": "00000000-0000-4000-8000-000100000001"} (1 row) SET === club read, RLS (wayclub_app) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit InitPlan 1 -> Seq Scan on persona Filter: (i = 1) -> Sort Sort Key: event.created_at DESC -> Bitmap Heap Scan on event Recheck Cond: ((club_id = (InitPlan 1).col1) AND (account_id = app.current_account_id())) Filter: (((deleted_at IS NULL) AND ((ANY (id = (hashed SubPlan 3).col1)) OR (ANY (id = (hashed SubPlan 5).col1)))) OR app.oversees_club(club_id) OR app.is_committee_of(club_id) OR app.is_member_of(club_id) OR (created_by = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) OR app.is_reviewer_for_club(club_id) OR app.is_university_admin() OR ((status = ANY ('{scheduled,registration_open,live}'::text[])) AND (guest_policy = ANY ('{institution,public_guests}'::text[])) AND (deleted_at IS NULL) AND (NOT app.club_is_suspended(club_id)))) -> BitmapAnd -> Bitmap Index Scan on idx_event_club Index Cond: (club_id = (InitPlan 1).col1) -> Bitmap Index Scan on idx_event_account Index Cond: (account_id = app.current_account_id()) SubPlan 3 -> Index Scan using idx_event_registration_user_created on event_registration r Index Cond: (user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) Filter: ((account_id = app.current_account_id()) AND ((user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) OR app.is_committee_of(club_id) OR app.is_university_admin())) SubPlan 5 -> Seq Scan on attendance a Filter: ((user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) AND (account_id = app.current_account_id()) AND ((user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) OR app.is_committee_of(club_id) OR app.is_university_admin())) (21 rows) === discovery read, RLS (wayclub_app) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit -> Sort Sort Key: event.created_at DESC -> Bitmap Heap Scan on event Recheck Cond: ((account_id = app.current_account_id()) AND (status = ANY ('{scheduled,registration_open,live}'::text[]))) Filter: (((deleted_at IS NULL) AND ((ANY (id = (hashed SubPlan 2).col1)) OR (ANY (id = (hashed SubPlan 4).col1)))) OR app.oversees_club(club_id) OR app.is_committee_of(club_id) OR app.is_member_of(club_id) OR (created_by = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) OR app.is_reviewer_for_club(club_id) OR app.is_university_admin() OR ((status = ANY ('{scheduled,registration_open,live}'::text[])) AND (guest_policy = ANY ('{institution,public_guests}'::text[])) AND (deleted_at IS NULL) AND (NOT app.club_is_suspended(club_id)))) -> BitmapAnd -> Bitmap Index Scan on idx_event_account Index Cond: (account_id = app.current_account_id()) -> Bitmap Index Scan on idx_event_status Index Cond: (status = ANY ('{scheduled,registration_open,live}'::text[])) SubPlan 2 -> Index Scan using idx_event_registration_user_created on event_registration r Index Cond: (user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) Filter: ((account_id = app.current_account_id()) AND ((user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) OR app.is_committee_of(club_id) OR app.is_university_admin())) SubPlan 4 -> Seq Scan on attendance a Filter: ((user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) AND (account_id = app.current_account_id()) AND ((user_id = (((NULLIF(current_setting('request.jwt.claims'::text, true), ''::text))::jsonb ->> 'sub'::text))::uuid) OR app.is_committee_of(club_id) OR app.is_university_admin())) (18 rows) RESET SET === club read, explicit filter (owner) QUERY PLAN --------------------------------------------------------------- Limit InitPlan 1 -> Seq Scan on persona Filter: (i = 1) InitPlan 2 -> Seq Scan on persona persona_1 Filter: (i = 1) -> Sort Sort Key: event.created_at DESC -> Bitmap Heap Scan on event Recheck Cond: (club_id = (InitPlan 1).col1) Filter: (account_id = (InitPlan 2).col1) -> Bitmap Index Scan on idx_event_club Index Cond: (club_id = (InitPlan 1).col1) (14 rows) === discovery read, explicit filter (owner) QUERY PLAN ------------------------------------------------------------------------------------- Limit InitPlan 1 -> Seq Scan on persona Filter: (i = 1) -> Sort Sort Key: event.created_at DESC -> Bitmap Heap Scan on event Recheck Cond: (account_id = (InitPlan 1).col1) Filter: (status = ANY ('{scheduled,registration_open,live}'::text[])) -> Bitmap Index Scan on idx_event_account Index Cond: (account_id = (InitPlan 1).col1) (11 rows) RESET === row-independent helper inside an OR, per row QUERY PLAN ------------------------------------------------------------------- Aggregate InitPlan 1 -> Seq Scan on persona Filter: (i = 1) -> Bitmap Heap Scan on event Recheck Cond: (account_id = (InitPlan 1).col1) Filter: (app.is_university_admin() OR (title = ''::text)) -> Bitmap Index Scan on idx_event_account Index Cond: (account_id = (InitPlan 1).col1) (9 rows) === same helper wrapped in a scalar sub-select QUERY PLAN ------------------------------------------------------------ Aggregate InitPlan 1 -> Seq Scan on persona Filter: (i = 1) InitPlan 2 -> Result -> Bitmap Heap Scan on event Recheck Cond: (account_id = (InitPlan 1).col1) Filter: ((InitPlan 2).col1 OR (title = ''::text)) -> Bitmap Index Scan on idx_event_account Index Cond: (account_id = (InitPlan 1).col1) (11 rows) ROLLBACK