explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YCUy

Settings
# exclusive inclusive rows x rows loops node
1. 211.021 4,231.076 ↓ 43,547.0 43,547 1

Sort (cost=751,156.65..751,156.66 rows=1 width=259) (actual time=4,216.115..4,231.076 rows=43,547 loops=1)

  • Output: e.record_type, insecure_record_types.name, e.workflow_template_api_name, wt.name, e.record_id, (w.team_member_ids[1]), (CASE w.status WHEN 'STARTED'::workflow_status THEN ((((('/records/'::text || e.record_type) || '/'::text) || (e.record_id)::text) || '/workflows/'::text) || insecure_stage_templates.workflow_template_api_name) ELSE NULL::text END), w.status, e.first_timestamp, (CASE WHEN (w.status = 'CLOSED'::workflow_status) THEN e.latest_timestamp ELSE NULL::timestamp with time zone END), e."timestamp", (CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.api_name ELSE (insecure_stage_templates.workflow_template_api_name || '_complete'::text) END), (CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.name ELSE 'Completed Workflow Stage'::text END), (CASE WHEN (insecure_stage_templates.status = 'archived'::stage_template_status) THEN true ELSE false END), (CASE WHEN ((w_1.stage_api_name IS NOT NULL) AND e.is_latest_timestamp) THEN true ELSE false END), (CASE WHEN (insecure_stage_templates."order" <> ((insecure_stage_templates_1."order" + 1))) THEN false ELSE true END), (CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates."order" ELSE ((insecure_stage_templates_1."order" + 1)) END), (CASE WHEN ((e.from_stage ~~ '%_complete'::text) AND e.is_first_timestamp) THEN 'N/A (start of workflow)'::text ELSE e.from_stage END), e.exited_stage_timestamp, e.days_in_stage
  • Sort Key: e.record_type, e.workflow_template_api_name, e.record_id, e."timestamp
  • Sort Method: external sort Disk: 8656kB
2. 88.479 4,020.055 ↓ 43,547.0 43,547 1

Nested Loop Left Join (cost=722,824.12..751,156.64 rows=1 width=259) (actual time=2,413.306..4,020.055 rows=43,547 loops=1)

  • Output: e.record_type, insecure_record_types.name, e.workflow_template_api_name, wt.name, e.record_id, w.team_member_ids[1], CASE w.status WHEN 'STARTED'::workflow_status THEN ((((('/records/'::text || e.record_type) || '/'::text) || (e.record_id)::text) || '/workflows/'::text) || insecure_stage_templates.workflow_template_api_name) ELSE NULL::text END, w.status, e.first_timestamp, CASE WHEN (w.status = 'CLOSED'::workflow_status) THEN e.latest_timestamp ELSE NULL::timestamp with time zone END, e."timestamp", CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.api_name ELSE (insecure_stage_templates.workflow_template_api_name || '_complete'::text) END, CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.name ELSE 'Completed Workflow Stage'::text END, CASE WHEN (insecure_stage_templates.status = 'archived'::stage_template_status) THEN true ELSE false END, CASE WHEN ((w_1.stage_api_name IS NOT NULL) AND e.is_latest_timestamp) THEN true ELSE false END, CASE WHEN (insecure_stage_templates."order" <> ((insecure_stage_templates_1."order" + 1))) THEN false ELSE true END, CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates."order" ELSE ((insecure_stage_templates_1."order" + 1)) END, CASE WHEN ((e.from_stage ~~ '%_complete'::text) AND e.is_first_timestamp) THEN 'N/A (start of workflow)'::text ELSE e.from_stage END, e.exited_stage_timestamp, e.days_in_stage
3. 93.060 3,583.200 ↓ 43,547.0 43,547 1

Nested Loop Semi Join (cost=722,823.41..739,818.42 rows=1 width=241) (actual time=2,413.259..3,583.200 rows=43,547 loops=1)

  • Output: e.record_type, e.workflow_template_api_name, e.record_id, e.first_timestamp, e.latest_timestamp, e."timestamp", e.is_latest_timestamp, e.from_stage, e.is_first_timestamp, e.exited_stage_timestamp, e.days_in_stage, e.to_stage, insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_record_types.name, wt.name, ((insecure_stage_templates_1."order" + 1)), w.team_member_ids, w.status
  • Join Filter: ((insecure_stage_templates.record_type = wt_1.record_type) AND (insecure_stage_templates.workflow_template_api_name = wt_1.api_name))
4. 60.669 3,359.499 ↓ 43,547.0 43,547 1

Nested Loop (cost=722,823.13..728,488.69 rows=1 width=355) (actual time=2,413.237..3,359.499 rows=43,547 loops=1)

  • Output: e.record_type, e.workflow_template_api_name, e.record_id, e.first_timestamp, e.latest_timestamp, e."timestamp", e.is_latest_timestamp, e.from_stage, e.is_first_timestamp, e.exited_stage_timestamp, e.days_in_stage, e.to_stage, insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type, insecure_record_types.name, insecure_record_types.api_name, wt.name, wt.record_type, wt.api_name, ((insecure_stage_templates_1."order" + 1)), w.team_member_ids, w.status, w.record_type, w.workflow_template_api_name
5. 88.551 2,776.266 ↓ 43,547.0 43,547 1

Nested Loop (cost=722,814.80..728,480.34 rows=1 width=351) (actual time=2,413.193..2,776.266 rows=43,547 loops=1)

  • Output: e.record_type, e.workflow_template_api_name, e.record_id, e.first_timestamp, e.latest_timestamp, e."timestamp", e.is_latest_timestamp, e.from_stage, e.is_first_timestamp, e.exited_stage_timestamp, e.days_in_stage, e.to_stage, insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type, insecure_record_types.name, insecure_record_types.api_name, wt.name, wt.record_type, wt.api_name, w.team_member_ids, w.status, w.record_type, w.workflow_template_api_name
  • Join Filter: ((insecure_stage_templates.record_type = wt.record_type) AND (insecure_stage_templates.workflow_template_api_name = wt.api_name))
6. 83.001 2,555.799 ↓ 43,972.0 43,972 1

Merge Join (cost=722,814.52..722,815.33 rows=1 width=255) (actual time=2,411.216..2,555.799 rows=43,972 loops=1)

  • Output: e.record_type, e.workflow_template_api_name, e.record_id, e.first_timestamp, e.latest_timestamp, e."timestamp", e.is_latest_timestamp, e.from_stage, e.is_first_timestamp, e.exited_stage_timestamp, e.days_in_stage, e.to_stage, insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type, insecure_record_types.name, insecure_record_types.api_name, w.team_member_ids, w.status, w.record_type, w.workflow_template_api_name
  • Merge Cond: ((insecure_stage_templates.record_type = e.record_type) AND (insecure_stage_templates.workflow_template_api_name = e.workflow_template_api_name) AND ((CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.api_name ELSE (insecure_stage_templates.workflow_template_api_name || '_complete'::text) END) = e.to_stage) AND (w.record_id = e.record_id))
7. 521.669 632.694 ↓ 1,829.4 82,323 1

Sort (cost=647.74..647.85 rows=45 width=152) (actual time=592.533..632.694 rows=82,323 loops=1)

  • Output: insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type, insecure_record_types.name, insecure_record_types.api_name, w.team_member_ids, w.status, w.record_type, w.workflow_template_api_name, w.record_id, (CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.api_name ELSE (insecure_stage_templates.workflow_template_api_name || '_complete'::text) END)
  • Sort Key: insecure_stage_templates.record_type, insecure_stage_templates.workflow_template_api_name, (CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.api_name ELSE (insecure_stage_templates.workflow_template_api_name || '_complete'::text) END), w.record_id
  • Sort Method: external merge Disk: 14016kB
8. 48.415 111.025 ↓ 1,829.4 82,324 1

Nested Loop (cost=264.78..646.50 rows=45 width=152) (actual time=0.353..111.025 rows=82,324 loops=1)

  • Output: insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type, insecure_record_types.name, insecure_record_types.api_name, w.team_member_ids, w.status, w.record_type, w.workflow_template_api_name, w.record_id, CASE WHEN (insecure_stage_templates."order" <> 0) THEN insecure_stage_templates.api_name ELSE (insecure_stage_templates.workflow_template_api_name || '_complete'::text) END
9. 0.105 0.494 ↓ 1.8 53 1

Merge Join (cost=264.35..265.31 rows=29 width=92) (actual time=0.329..0.494 rows=53 loops=1)

  • Output: insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type, insecure_record_types.name, insecure_record_types.api_name
  • Merge Cond: (insecure_stage_templates.record_type = (insecure_record_types.api_name)::text)
10. 0.076 0.155 ↑ 1.1 53 1

Sort (cost=109.50..109.64 rows=57 width=67) (actual time=0.131..0.155 rows=53 loops=1)

  • Output: insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type
  • Sort Key: insecure_stage_templates.record_type
  • Sort Method: quicksort Memory: 32kB
11. 0.050 0.079 ↑ 1.1 53 1

Bitmap Heap Scan on records.insecure_stage_templates (cost=5.01..107.84 rows=57 width=67) (actual time=0.037..0.079 rows=53 loops=1)

  • Output: insecure_stage_templates.workflow_template_api_name, insecure_stage_templates."order", insecure_stage_templates.api_name, insecure_stage_templates.name, insecure_stage_templates.status, insecure_stage_templates.record_type
  • Recheck Cond: ((insecure_stage_templates.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_stage_templates."order" >= 0))
  • Heap Blocks: exact=13
12. 0.029 0.029 ↑ 1.1 53 1

Bitmap Index Scan on insecure_stage_templates_organization_id_record_type_workfl_key (cost=0.00..5.00 rows=57 width=0) (actual time=0.029..0.029 rows=53 loops=1)

  • Index Cond: ((insecure_stage_templates.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_stage_templates."order" >= 0))
13. 0.168 0.234 ↓ 1.5 113 1

Sort (cost=154.85..155.04 rows=76 width=25) (actual time=0.195..0.234 rows=113 loops=1)

  • Output: insecure_record_types.name, insecure_record_types.api_name
  • Sort Key: insecure_record_types.api_name
  • Sort Method: quicksort Memory: 31kB
14. 0.066 0.066 ↑ 1.0 76 1

Index Scan using record_types_organization_id on records.insecure_record_types (cost=0.29..152.48 rows=76 width=25) (actual time=0.012..0.066 rows=76 loops=1)

  • Output: insecure_record_types.name, insecure_record_types.api_name
  • Index Cond: (insecure_record_types.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
15. 62.116 62.116 ↓ 1,553.0 1,553 53

Index Scan using insecure_workflows_pkey on records.insecure_workflows w (cost=0.43..13.13 rows=1 width=60) (actual time=0.008..1.172 rows=1,553 loops=53)

  • Output: w.organization_id, w.record_type, w.workflow_template_api_name, w.record_id, w.stage_api_name, w.team_member_ids, w.status, w.planning_input_date, w.enable_auto_replanning, w.enable_workflow_planning, w.timezone
  • Index Cond: ((w.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (w.record_type = insecure_stage_templates.record_type) AND (w.workflow_template_api_name = insecure_stage_templates.workflow_template_api_name))
16. 270.605 1,840.104 ↓ 43,972.0 43,972 1

Sort (cost=722,166.78..722,166.78 rows=1 width=107) (actual time=1,818.676..1,840.104 rows=43,972 loops=1)

  • Output: e.record_type, e.workflow_template_api_name, e.record_id, e.first_timestamp, e.latest_timestamp, e."timestamp", e.is_latest_timestamp, e.from_stage, e.is_first_timestamp, e.exited_stage_timestamp, e.days_in_stage, e.to_stage
  • Sort Key: e.record_type, e.workflow_template_api_name, e.to_stage, e.record_id
  • Sort Method: external sort Disk: 5536kB
17. 19.448 1,569.499 ↓ 43,972.0 43,972 1

Subquery Scan on e (cost=720,697.74..722,166.77 rows=1 width=107) (actual time=1,473.377..1,569.499 rows=43,972 loops=1)

  • Output: e.record_type, e.workflow_template_api_name, e.record_id, e.first_timestamp, e.latest_timestamp, e."timestamp", e.is_latest_timestamp, e.from_stage, e.is_first_timestamp, e.exited_stage_timestamp, e.days_in_stage, e.to_stage
18. 58.038 1,550.051 ↓ 43,972.0 43,972 1

Hash Right Join (cost=720,697.74..722,166.76 rows=1 width=107) (actual time=1,473.376..1,550.051 rows=43,972 loops=1)

  • Output: insecure_transition_events.record_type, insecure_transition_events.workflow_template_api_name, insecure_transition_events.record_id, insecure_transition_events."timestamp", insecure_transition_events.from_stage, insecure_transition_events.to_stage, e_1.is_first_timestamp, e_1.is_latest_timestamp, e_1.first_timestamp, e_1.latest_timestamp, en."timestamp", date_part('day'::text, (COALESCE(en."timestamp", now()) - e_1."timestamp"))
  • Hash Cond: ((en.record_type = e_1.record_type) AND (en.workflow_template_api_name = e_1.workflow_template_api_name) AND (en.record_id = e_1.record_id) AND (en.rank_number = (e_1.rank_number + 1)))
19.          

CTE e

20. 48.131 1,124.081 ↓ 1.1 43,972 1

WindowAgg (cost=706,078.35..707,294.07 rows=40,524 width=130) (actual time=1,061.918..1,124.081 rows=43,972 loops=1)

  • Output: insecure_transition_events_1.record_type, insecure_transition_events_1.workflow_template_api_name, insecure_transition_events_1.record_id, insecure_transition_events_1."timestamp", insecure_transition_events_1.from_stage, insecure_transition_events_1.to_stage, CASE WHEN (insecure_transition_events_1."timestamp" = insecure_transition_events_2."timestamp") THEN true ELSE false END, CASE WHEN (insecure_transition_events_1."timestamp" = insecure_transition_events_3."timestamp") THEN true ELSE false END, insecure_transition_events_2."timestamp", insecure_transition_events_3."timestamp", rank() OVER (?), insecure_transition_events_1.record_type, insecure_transition_events_1.workflow_template_api_name, insecure_transition_events_1.record_id
21. 156.862 1,075.950 ↓ 1.1 43,972 1

Sort (cost=706,078.35..706,179.66 rows=40,524 width=89) (actual time=1,061.902..1,075.950 rows=43,972 loops=1)

  • Output: insecure_transition_events_1."timestamp", insecure_transition_events_1.record_type, insecure_transition_events_1.workflow_template_api_name, insecure_transition_events_1.record_id, insecure_transition_events_1.from_stage, insecure_transition_events_1.to_stage, insecure_transition_events_2."timestamp", insecure_transition_events_3."timestamp
  • Sort Key: insecure_transition_events_1.record_type, insecure_transition_events_1.workflow_template_api_name, insecure_transition_events_1.record_id, insecure_transition_events_1."timestamp
  • Sort Method: external sort Disk: 4512kB
22. 51.055 919.088 ↓ 1.1 43,972 1

Nested Loop (cost=17.73..702,976.95 rows=40,524 width=89) (actual time=0.039..919.088 rows=43,972 loops=1)

  • Output: insecure_transition_events_1."timestamp", insecure_transition_events_1.record_type, insecure_transition_events_1.workflow_template_api_name, insecure_transition_events_1.record_id, insecure_transition_events_1.from_stage, insecure_transition_events_1.to_stage, insecure_transition_events_2."timestamp", insecure_transition_events_3."timestamp
23. 53.792 472.285 ↓ 1.1 43,972 1

Nested Loop (cost=9.14..353,862.69 rows=40,524 width=81) (actual time=0.026..472.285 rows=43,972 loops=1)

  • Output: insecure_transition_events_1.record_type, insecure_transition_events_1.workflow_template_api_name, insecure_transition_events_1.record_id, insecure_transition_events_1."timestamp", insecure_transition_events_1.from_stage, insecure_transition_events_1.to_stage, insecure_transition_events_2."timestamp
24. 22.745 22.745 ↓ 1.1 43,972 1

Index Only Scan using insecure_transition_events_pkey on records.insecure_transition_events insecure_transition_events_1 (cost=0.56..4,748.43 rows=40,524 width=73) (actual time=0.007..22.745 rows=43,972 loops=1)

  • Output: insecure_transition_events_1.organization_id, insecure_transition_events_1.record_type, insecure_transition_events_1.record_id, insecure_transition_events_1.from_stage, insecure_transition_events_1.to_stage, insecure_transition_events_1.workflow_template_api_name, insecure_transition_events_1."timestamp
  • Index Cond: (insecure_transition_events_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 8749
25. 43.972 395.748 ↑ 1.0 1 43,972

Limit (cost=8.59..8.60 rows=1 width=8) (actual time=0.008..0.009 rows=1 loops=43,972)

  • Output: insecure_transition_events_2."timestamp
26. 131.916 351.776 ↑ 1.0 1 43,972

Sort (cost=8.59..8.60 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=43,972)

  • Output: insecure_transition_events_2."timestamp
  • Sort Key: insecure_transition_events_2."timestamp
  • Sort Method: quicksort Memory: 25kB
27. 219.860 219.860 ↓ 4.0 4 43,972

Index Only Scan using insecure_transition_events_pkey on records.insecure_transition_events insecure_transition_events_2 (cost=0.56..8.58 rows=1 width=8) (actual time=0.003..0.005 rows=4 loops=43,972)

  • Output: insecure_transition_events_2."timestamp
  • Index Cond: ((insecure_transition_events_2.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_transition_events_2.record_type = insecure_transition_events_1.record_type) AND (insecure_transition_events_2.record_id = insecure_transition_events_1.record_id) AND (insecure_transition_events_2.workflow_template_api_name = insecure_transition_events_1.workflow_template_api_name))
  • Heap Fetches: 29309
28. 43.972 395.748 ↑ 1.0 1 43,972

Limit (cost=8.59..8.60 rows=1 width=8) (actual time=0.008..0.009 rows=1 loops=43,972)

  • Output: insecure_transition_events_3."timestamp
29. 131.916 351.776 ↑ 1.0 1 43,972

Sort (cost=8.59..8.60 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=43,972)

  • Output: insecure_transition_events_3."timestamp
  • Sort Key: insecure_transition_events_3."timestamp" DESC
  • Sort Method: quicksort Memory: 25kB
30. 219.860 219.860 ↓ 4.0 4 43,972

Index Only Scan using insecure_transition_events_pkey on records.insecure_transition_events insecure_transition_events_3 (cost=0.56..8.58 rows=1 width=8) (actual time=0.003..0.005 rows=4 loops=43,972)

  • Output: insecure_transition_events_3."timestamp
  • Index Cond: ((insecure_transition_events_3.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_transition_events_3.record_type = insecure_transition_events_1.record_type) AND (insecure_transition_events_3.record_id = insecure_transition_events_1.record_id) AND (insecure_transition_events_3.workflow_template_api_name = insecure_transition_events_1.workflow_template_api_name))
  • Heap Fetches: 29309
31. 18.703 18.703 ↓ 1.1 43,972 1

CTE Scan on e en (cost=0.00..810.48 rows=40,524 width=84) (actual time=0.012..18.703 rows=43,972 loops=1)

  • Output: en.record_type, en.workflow_template_api_name, en.record_id, en."timestamp", en.from_stage, en.to_stage, en.is_first_timestamp, en.is_latest_timestamp, en.first_timestamp, en.latest_timestamp, en.rank_number
32. 32.345 1,473.310 ↓ 43,972.0 43,972 1

Hash (cost=13,403.66..13,403.66 rows=1 width=175) (actual time=1,473.310..1,473.310 rows=43,972 loops=1)

  • Output: insecure_transition_events.record_type, insecure_transition_events.workflow_template_api_name, insecure_transition_events.record_id, insecure_transition_events."timestamp", insecure_transition_events.from_stage, insecure_transition_events.to_stage, e_1.is_first_timestamp, e_1.is_latest_timestamp, e_1.first_timestamp, e_1.latest_timestamp, e_1."timestamp", e_1.record_type, e_1.workflow_template_api_name, e_1.record_id, e_1.rank_number
  • Buckets: 65536 (originally 1024) Batches: 2 (originally 1) Memory Usage: 6479kB
33. 70.547 1,440.965 ↓ 43,972.0 43,972 1

Merge Join (cost=7,237.44..13,403.66 rows=1 width=175) (actual time=1,313.878..1,440.965 rows=43,972 loops=1)

  • Output: insecure_transition_events.record_type, insecure_transition_events.workflow_template_api_name, insecure_transition_events.record_id, insecure_transition_events."timestamp", insecure_transition_events.from_stage, insecure_transition_events.to_stage, e_1.is_first_timestamp, e_1.is_latest_timestamp, e_1.first_timestamp, e_1.latest_timestamp, e_1."timestamp", e_1.record_type, e_1.workflow_template_api_name, e_1.record_id, e_1.rank_number
  • Merge Cond: ((insecure_transition_events.record_type = e_1.record_type) AND (insecure_transition_events.record_id = e_1.record_id) AND (insecure_transition_events.from_stage = e_1.from_stage) AND (insecure_transition_events.to_stage = e_1.to_stage) AND (insecure_transition_events.workflow_template_api_name = e_1.workflow_template_api_name) AND (insecure_transition_events."timestamp" = e_1."timestamp"))
34. 23.849 23.849 ↓ 1.1 43,972 1

Index Only Scan using insecure_transition_events_pkey on records.insecure_transition_events (cost=0.56..4,748.43 rows=40,524 width=73) (actual time=0.022..23.849 rows=43,972 loops=1)

  • Output: insecure_transition_events.organization_id, insecure_transition_events.record_type, insecure_transition_events.record_id, insecure_transition_events.from_stage, insecure_transition_events.to_stage, insecure_transition_events.workflow_template_api_name, insecure_transition_events."timestamp
  • Index Cond: (insecure_transition_events.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 8749
35. 18.625 1,346.569 ↓ 1.1 43,972 1

Materialize (cost=7,236.88..7,439.50 rows=40,524 width=166) (actual time=1,313.850..1,346.569 rows=43,972 loops=1)

  • Output: e_1.is_first_timestamp, e_1.is_latest_timestamp, e_1.first_timestamp, e_1.latest_timestamp, e_1."timestamp", e_1.record_type, e_1.workflow_template_api_name, e_1.record_id, e_1.from_stage, e_1.to_stage, e_1.rank_number
36. 152.243 1,327.944 ↓ 1.1 43,972 1

Sort (cost=7,236.88..7,338.19 rows=40,524 width=166) (actual time=1,313.848..1,327.944 rows=43,972 loops=1)

  • Output: e_1.is_first_timestamp, e_1.is_latest_timestamp, e_1.first_timestamp, e_1.latest_timestamp, e_1."timestamp", e_1.record_type, e_1.workflow_template_api_name, e_1.record_id, e_1.from_stage, e_1.to_stage, e_1.rank_number
  • Sort Key: e_1.record_type, e_1.record_id, e_1.from_stage, e_1.to_stage, e_1.workflow_template_api_name, e_1."timestamp
  • Sort Method: external sort Disk: 5200kB
37. 1,175.701 1,175.701 ↓ 1.1 43,972 1

CTE Scan on e e_1 (cost=0.00..810.48 rows=40,524 width=166) (actual time=1,061.922..1,175.701 rows=43,972 loops=1)

  • Output: e_1.is_first_timestamp, e_1.is_latest_timestamp, e_1.first_timestamp, e_1.latest_timestamp, e_1."timestamp", e_1.record_type, e_1.workflow_template_api_name, e_1.record_id, e_1.from_stage, e_1.to_stage, e_1.rank_number
38. 131.916 131.916 ↑ 1.0 1 43,972

Index Scan using insecure_workflow_templates_organization_id_record_type_sub_idx on records.insecure_workflow_templates wt (cost=0.29..5,665.00 rows=1 width=96) (actual time=0.003..0.003 rows=1 loops=43,972)

  • Output: wt.name, wt.record_type, wt.api_name
  • Index Cond: ((wt.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (wt.record_type = w.record_type))
  • Filter: ((wt.status <> 'archived'::workflow_template_status) AND (w.workflow_template_api_name = wt.api_name) AND ((wt.status = ANY ('{published,archived}'::workflow_template_status[])) OR ((current_setting('lanetix.permissions'::text))::text[] && '{customer-administrator,lanetix-staff}'::text[]) OR (SubPlan 6)))
  • Rows Removed by Filter: 0
39.          

SubPlan (for Index Scan)

40. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=5,662.11..6,297.68 rows=249 width=0) (never executed)

  • Filter: ((COALESCE((CASE WHEN NULLIF((NOT users_1.active), false) THEN 'archived'::group_status ELSE NULL::group_status END), g_1.status) <> 'principal'::group_status) OR (alternatives: SubPlan 1 or hashed SubPlan 2))
41.          

Initplan (for Nested Loop Left Join)

42. 0.000 0.000 ↓ 0.0 0

Merge Left Join (cost=4,790.53..5,660.94 rows=103 width=4) (never executed)

  • Output: g.id
  • Merge Cond: (g.id = insecure_temp_user_group_2.group_id)
  • Filter: (COALESCE((CASE WHEN NULLIF((NOT users.active), false) THEN 'archived'::group_status ELSE NULL::group_status END), g.status) = 'everyone'::group_status)
43. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_pkey on records.insecure_temp_group g (cost=0.29..503.28 rows=3,205 width=8) (never executed)

  • Output: g.organization_id, g.id, g.status, g.name, g.description, g.reference_metadata
  • Index Cond: (g.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
44. 0.000 0.000 ↓ 0.0 0

Sort (cost=4,790.23..4,796.91 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_2.group_id, (CASE WHEN NULLIF((NOT users.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
  • Sort Key: insecure_temp_user_group_2.group_id
45. 0.000 0.000 ↓ 0.0 0

Hash Right Join (cost=156.73..4,638.15 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_2.group_id, (CASE WHEN NULLIF((NOT users.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
  • Hash Cond: (users.id = insecure_temp_user_group_2.user_id)
46. 0.000 0.000 ↓ 0.0 0

Index Scan using users_organization_id on public.users (cost=0.29..4,467.44 rows=2,953 width=8) (never executed)

  • Output: users.id, CASE WHEN NULLIF((NOT users.active), false) THEN 'archived'::group_status ELSE NULL::group_status END
  • Index Cond: (users.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
47. 0.000 0.000 ↓ 0.0 0

Hash (cost=123.03..123.03 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_2.group_id, insecure_temp_user_group_2.user_id
48. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_2 (cost=0.29..123.03 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_2.group_id, insecure_temp_user_group_2.user_id
  • Index Cond: (insecure_temp_user_group_2.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 0
49. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.60..136.09 rows=39 width=8) (never executed)

  • Output: g_1.id, g_1.status
50. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_permissio_organization_id_schema_permis_idx on records.insecure_temp_group_permission p (cost=0.30..127.77 rows=1 width=4) (never executed)

  • Output: p.organization_id, p.schema, p.group_id, p.permission
  • Index Cond: ((p.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (p.schema = 'records'::text) AND (p.permission = (((('recordType'::ltree || wt.record_type) || 'workflow'::ltree) || ("substring"(lower(wt.api_name), 1, 31))::ltree) || 'permissions.admin'::ltree)))
  • Filter: ((p.group_id = $2) OR (alternatives: SubPlan 4 or hashed SubPlan 5))
51.          

SubPlan (for Index Scan)

52. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.72..119.44 rows=1 width=0) (never executed)

53. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_3 (cost=0.30..8.32 rows=1 width=4) (never executed)

  • Output: insecure_temp_user_group_3.organization_id, insecure_temp_user_group_3.user_id, insecure_temp_user_group_3.group_id
  • Index Cond: ((insecure_temp_user_group_3.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_3.user_id = (current_setting('lanetix.user_id'::text))::integer))
  • Heap Fetches: 0
54. 0.000 0.000 ↓ 0.0 0

Index Scan using organization_id_descendent_id on records.insecure_temp_group_closure (cost=0.42..111.11 rows=1 width=4) (never executed)

  • Output: insecure_temp_group_closure.organization_id, insecure_temp_group_closure.ancestor_id, insecure_temp_group_closure.descendent_id
  • Index Cond: ((insecure_temp_group_closure.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_group_closure.descendent_id = insecure_temp_user_group_3.group_id))
  • Filter: (insecure_temp_group_closure.ancestor_id = p.group_id)
55. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.72..119.70 rows=222 width=4) (never executed)

  • Output: insecure_temp_group_closure_1.ancestor_id
56. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_4 (cost=0.30..8.32 rows=1 width=4) (never executed)

  • Output: insecure_temp_user_group_4.organization_id, insecure_temp_user_group_4.user_id, insecure_temp_user_group_4.group_id
  • Index Cond: ((insecure_temp_user_group_4.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_4.user_id = (current_setting('lanetix.user_id'::text))::integer))
  • Heap Fetches: 0
57. 0.000 0.000 ↓ 0.0 0

Index Scan using organization_id_descendent_id on records.insecure_temp_group_closure insecure_temp_group_closure_1 (cost=0.42..111.02 rows=36 width=8) (never executed)

  • Output: insecure_temp_group_closure_1.organization_id, insecure_temp_group_closure_1.ancestor_id, insecure_temp_group_closure_1.descendent_id
  • Index Cond: ((insecure_temp_group_closure_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_group_closure_1.descendent_id = insecure_temp_user_group_4.group_id))
58. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_pkey on records.insecure_temp_group g_1 (cost=0.29..8.31 rows=1 width=8) (never executed)

  • Output: g_1.organization_id, g_1.id, g_1.status, g_1.name, g_1.description, g_1.reference_metadata
  • Index Cond: ((g_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (g_1.id = p.group_id))
59. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.58..4.51 rows=1 width=8) (never executed)

  • Output: insecure_temp_user_group_5.group_id, (CASE WHEN NULLIF((NOT users_1.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
60. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_5 (cost=0.29..0.40 rows=1 width=8) (never executed)

  • Output: insecure_temp_user_group_5.organization_id, insecure_temp_user_group_5.user_id, insecure_temp_user_group_5.group_id
  • Index Cond: ((insecure_temp_user_group_5.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_5.group_id = g_1.id))
61. 0.000 0.000 ↓ 0.0 0

Index Scan using users_pkey on public.users users_1 (cost=0.29..4.10 rows=1 width=8) (never executed)

  • Output: users_1.id, CASE WHEN NULLIF((NOT users_1.active), false) THEN 'archived'::group_status ELSE NULL::group_status END
  • Index Cond: (users_1.id = insecure_temp_user_group_5.user_id)
  • Filter: (users_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
62.          

SubPlan (for Nested Loop Left Join)

63. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group (cost=0.29..8.31 rows=1 width=0) (never executed)

  • Index Cond: ((insecure_temp_user_group.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group.group_id = g_1.id))
  • Heap Fetches: 0
64. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_1 (cost=0.29..111.03 rows=2,672 width=4) (never executed)

  • Output: insecure_temp_user_group_1.group_id
  • Index Cond: (insecure_temp_user_group_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 0
65. 87.094 522.564 ↑ 1.0 1 43,547

Limit (cost=8.32..8.33 rows=1 width=4) (actual time=0.011..0.012 rows=1 loops=43,547)

  • Output: ((insecure_stage_templates_1."order" + 1))
66. 174.188 435.470 ↑ 1.0 1 43,547

Sort (cost=8.32..8.33 rows=1 width=4) (actual time=0.010..0.010 rows=1 loops=43,547)

  • Output: ((insecure_stage_templates_1."order" + 1))
  • Sort Key: ((insecure_stage_templates_1."order" + 1)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
67. 261.282 261.282 ↓ 6.0 6 43,547

Index Scan using insecure_stage_templates_pkey on records.insecure_stage_templates insecure_stage_templates_1 (cost=0.29..8.31 rows=1 width=4) (actual time=0.003..0.006 rows=6 loops=43,547)

  • Output: (insecure_stage_templates_1."order" + 1)
  • Index Cond: ((insecure_stage_templates_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_stage_templates.record_type = insecure_stage_templates_1.record_type) AND (insecure_stage_templates.workflow_template_api_name = insecure_stage_templates_1.workflow_template_api_name))
68. 130.641 130.641 ↑ 1.0 1 43,547

Index Scan using insecure_workflow_templates_organization_id_record_type_sub_idx on records.insecure_workflow_templates wt_1 (cost=0.29..5,665.00 rows=1 width=64) (actual time=0.003..0.003 rows=1 loops=43,547)

  • Output: wt_1.record_type, wt_1.api_name
  • Index Cond: ((wt_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (wt_1.record_type = w.record_type))
  • Filter: ((w.workflow_template_api_name = wt_1.api_name) AND (((current_setting('lanetix.permissions'::text))::text[] && '{customer-administrator,lanetix-staff}'::text[]) OR (SubPlan 12)))
  • Rows Removed by Filter: 0
69.          

SubPlan (for Index Scan)

70. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=5,662.12..6,297.69 rows=249 width=0) (never executed)

  • Filter: ((COALESCE((CASE WHEN NULLIF((NOT users_3.active), false) THEN 'archived'::group_status ELSE NULL::group_status END), g_3.status) <> 'principal'::group_status) OR (alternatives: SubPlan 7 or hashed SubPlan 8))
71.          

Initplan (for Nested Loop Left Join)

72. 0.000 0.000 ↓ 0.0 0

Merge Left Join (cost=4,790.53..5,660.94 rows=103 width=4) (never executed)

  • Output: g_2.id
  • Merge Cond: (g_2.id = insecure_temp_user_group_8.group_id)
  • Filter: (COALESCE((CASE WHEN NULLIF((NOT users_2.active), false) THEN 'archived'::group_status ELSE NULL::group_status END), g_2.status) = 'everyone'::group_status)
73. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_pkey on records.insecure_temp_group g_2 (cost=0.29..503.28 rows=3,205 width=8) (never executed)

  • Output: g_2.organization_id, g_2.id, g_2.status, g_2.name, g_2.description, g_2.reference_metadata
  • Index Cond: (g_2.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
74. 0.000 0.000 ↓ 0.0 0

Sort (cost=4,790.23..4,796.91 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_8.group_id, (CASE WHEN NULLIF((NOT users_2.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
  • Sort Key: insecure_temp_user_group_8.group_id
75. 0.000 0.000 ↓ 0.0 0

Hash Right Join (cost=156.73..4,638.15 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_8.group_id, (CASE WHEN NULLIF((NOT users_2.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
  • Hash Cond: (users_2.id = insecure_temp_user_group_8.user_id)
76. 0.000 0.000 ↓ 0.0 0

Index Scan using users_organization_id on public.users users_2 (cost=0.29..4,467.44 rows=2,953 width=8) (never executed)

  • Output: users_2.id, CASE WHEN NULLIF((NOT users_2.active), false) THEN 'archived'::group_status ELSE NULL::group_status END
  • Index Cond: (users_2.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
77. 0.000 0.000 ↓ 0.0 0

Hash (cost=123.03..123.03 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_8.group_id, insecure_temp_user_group_8.user_id
78. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_8 (cost=0.29..123.03 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_8.group_id, insecure_temp_user_group_8.user_id
  • Index Cond: (insecure_temp_user_group_8.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 0
79. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.60..136.09 rows=39 width=8) (never executed)

  • Output: g_3.id, g_3.status
80. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_permissio_organization_id_schema_permis_idx on records.insecure_temp_group_permission p_1 (cost=0.31..127.77 rows=1 width=4) (never executed)

  • Output: p_1.organization_id, p_1.schema, p_1.group_id, p_1.permission
  • Index Cond: ((p_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (p_1.schema = 'records'::text) AND (p_1.permission = (((('recordType'::ltree || (wt_1.record_type)::ltree) || 'workflow'::ltree) || ("substring"(lower(wt_1.api_name), 1, 31))::ltree) || 'permissions.read'::ltree)))
  • Filter: ((p_1.group_id = $14) OR (alternatives: SubPlan 10 or hashed SubPlan 11))
81.          

SubPlan (for Index Scan)

82. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.72..119.44 rows=1 width=0) (never executed)

83. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_9 (cost=0.30..8.32 rows=1 width=4) (never executed)

  • Output: insecure_temp_user_group_9.organization_id, insecure_temp_user_group_9.user_id, insecure_temp_user_group_9.group_id
  • Index Cond: ((insecure_temp_user_group_9.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_9.user_id = (current_setting('lanetix.user_id'::text))::integer))
  • Heap Fetches: 0
84. 0.000 0.000 ↓ 0.0 0

Index Scan using organization_id_descendent_id on records.insecure_temp_group_closure insecure_temp_group_closure_2 (cost=0.42..111.11 rows=1 width=4) (never executed)

  • Output: insecure_temp_group_closure_2.organization_id, insecure_temp_group_closure_2.ancestor_id, insecure_temp_group_closure_2.descendent_id
  • Index Cond: ((insecure_temp_group_closure_2.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_group_closure_2.descendent_id = insecure_temp_user_group_9.group_id))
  • Filter: (insecure_temp_group_closure_2.ancestor_id = p_1.group_id)
85. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.72..119.70 rows=222 width=4) (never executed)

  • Output: insecure_temp_group_closure_3.ancestor_id
86. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_10 (cost=0.30..8.32 rows=1 width=4) (never executed)

  • Output: insecure_temp_user_group_10.organization_id, insecure_temp_user_group_10.user_id, insecure_temp_user_group_10.group_id
  • Index Cond: ((insecure_temp_user_group_10.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_10.user_id = (current_setting('lanetix.user_id'::text))::integer))
  • Heap Fetches: 0
87. 0.000 0.000 ↓ 0.0 0

Index Scan using organization_id_descendent_id on records.insecure_temp_group_closure insecure_temp_group_closure_3 (cost=0.42..111.02 rows=36 width=8) (never executed)

  • Output: insecure_temp_group_closure_3.organization_id, insecure_temp_group_closure_3.ancestor_id, insecure_temp_group_closure_3.descendent_id
  • Index Cond: ((insecure_temp_group_closure_3.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_group_closure_3.descendent_id = insecure_temp_user_group_10.group_id))
88. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_pkey on records.insecure_temp_group g_3 (cost=0.29..8.31 rows=1 width=8) (never executed)

  • Output: g_3.organization_id, g_3.id, g_3.status, g_3.name, g_3.description, g_3.reference_metadata
  • Index Cond: ((g_3.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (g_3.id = p_1.group_id))
89. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.58..4.51 rows=1 width=8) (never executed)

  • Output: insecure_temp_user_group_11.group_id, (CASE WHEN NULLIF((NOT users_3.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
90. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_11 (cost=0.29..0.40 rows=1 width=8) (never executed)

  • Output: insecure_temp_user_group_11.organization_id, insecure_temp_user_group_11.user_id, insecure_temp_user_group_11.group_id
  • Index Cond: ((insecure_temp_user_group_11.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_11.group_id = g_3.id))
91. 0.000 0.000 ↓ 0.0 0

Index Scan using users_pkey on public.users users_3 (cost=0.29..4.10 rows=1 width=8) (never executed)

  • Output: users_3.id, CASE WHEN NULLIF((NOT users_3.active), false) THEN 'archived'::group_status ELSE NULL::group_status END
  • Index Cond: (users_3.id = insecure_temp_user_group_11.user_id)
  • Filter: (users_3.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
92.          

SubPlan (for Nested Loop Left Join)

93. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_6 (cost=0.29..8.31 rows=1 width=0) (never executed)

  • Index Cond: ((insecure_temp_user_group_6.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_6.group_id = g_3.id))
  • Heap Fetches: 0
94. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_7 (cost=0.29..111.03 rows=2,672 width=4) (never executed)

  • Output: insecure_temp_user_group_7.group_id
  • Index Cond: (insecure_temp_user_group_7.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 0
95. 113.540 348.376 ↓ 0.0 0 43,547

Nested Loop Semi Join (cost=0.71..11,338.17 rows=1 width=41) (actual time=0.007..0.008 rows=0 loops=43,547)

  • Output: w_1.stage_api_name, w_1.record_type, w_1.workflow_template_api_name, w_1.record_id
96. 174.188 174.188 ↓ 0.0 0 43,547

Index Scan using insecure_workflows_pkey on records.insecure_workflows w_1 (cost=0.43..8.46 rows=1 width=41) (actual time=0.004..0.004 rows=0 loops=43,547)

  • Output: w_1.organization_id, w_1.record_type, w_1.workflow_template_api_name, w_1.record_id, w_1.stage_api_name, w_1.team_member_ids, w_1.status, w_1.planning_input_date, w_1.enable_auto_replanning, w_1.enable_workflow_planning, w_1.timezone
  • Index Cond: ((w_1.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (e.record_type = w_1.record_type) AND (e.record_id = w_1.record_id) AND (e.workflow_template_api_name = w_1.workflow_template_api_name))
  • Filter: (e.to_stage = w_1.stage_api_name)
  • Rows Removed by Filter: 1
97. 60.648 60.648 ↑ 1.0 1 20,216

Index Scan using insecure_workflow_templates_organization_id_record_type_sub_idx on records.insecure_workflow_templates wt_2 (cost=0.29..5,665.00 rows=1 width=64) (actual time=0.003..0.003 rows=1 loops=20,216)

  • Output: wt_2.record_type, wt_2.api_name
  • Index Cond: ((wt_2.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (wt_2.record_type = w_1.record_type))
  • Filter: ((w_1.workflow_template_api_name = wt_2.api_name) AND (((current_setting('lanetix.permissions'::text))::text[] && '{customer-administrator,lanetix-staff}'::text[]) OR (SubPlan 18)))
  • Rows Removed by Filter: 0
98.          

SubPlan (for Index Scan)

99. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=5,662.12..6,297.69 rows=249 width=0) (never executed)

  • Filter: ((COALESCE((CASE WHEN NULLIF((NOT users_5.active), false) THEN 'archived'::group_status ELSE NULL::group_status END), g_5.status) <> 'principal'::group_status) OR (alternatives: SubPlan 13 or hashed SubPlan 14))
100.          

Initplan (for Nested Loop Left Join)

101. 0.000 0.000 ↓ 0.0 0

Merge Left Join (cost=4,790.53..5,660.94 rows=103 width=4) (never executed)

  • Output: g_4.id
  • Merge Cond: (g_4.id = insecure_temp_user_group_14.group_id)
  • Filter: (COALESCE((CASE WHEN NULLIF((NOT users_4.active), false) THEN 'archived'::group_status ELSE NULL::group_status END), g_4.status) = 'everyone'::group_status)
102. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_pkey on records.insecure_temp_group g_4 (cost=0.29..503.28 rows=3,205 width=8) (never executed)

  • Output: g_4.organization_id, g_4.id, g_4.status, g_4.name, g_4.description, g_4.reference_metadata
  • Index Cond: (g_4.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
103. 0.000 0.000 ↓ 0.0 0

Sort (cost=4,790.23..4,796.91 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_14.group_id, (CASE WHEN NULLIF((NOT users_4.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
  • Sort Key: insecure_temp_user_group_14.group_id
104. 0.000 0.000 ↓ 0.0 0

Hash Right Join (cost=156.73..4,638.15 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_14.group_id, (CASE WHEN NULLIF((NOT users_4.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
  • Hash Cond: (users_4.id = insecure_temp_user_group_14.user_id)
105. 0.000 0.000 ↓ 0.0 0

Index Scan using users_organization_id on public.users users_4 (cost=0.29..4,467.44 rows=2,953 width=8) (never executed)

  • Output: users_4.id, CASE WHEN NULLIF((NOT users_4.active), false) THEN 'archived'::group_status ELSE NULL::group_status END
  • Index Cond: (users_4.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
106. 0.000 0.000 ↓ 0.0 0

Hash (cost=123.03..123.03 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_14.group_id, insecure_temp_user_group_14.user_id
107. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_14 (cost=0.29..123.03 rows=2,672 width=8) (never executed)

  • Output: insecure_temp_user_group_14.group_id, insecure_temp_user_group_14.user_id
  • Index Cond: (insecure_temp_user_group_14.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 0
108. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.60..136.09 rows=39 width=8) (never executed)

  • Output: g_5.id, g_5.status
109. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_permissio_organization_id_schema_permis_idx on records.insecure_temp_group_permission p_2 (cost=0.31..127.77 rows=1 width=4) (never executed)

  • Output: p_2.organization_id, p_2.schema, p_2.group_id, p_2.permission
  • Index Cond: ((p_2.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (p_2.schema = 'records'::text) AND (p_2.permission = (((('recordType'::ltree || (wt_2.record_type)::ltree) || 'workflow'::ltree) || ("substring"(lower(wt_2.api_name), 1, 31))::ltree) || 'permissions.read'::ltree)))
  • Filter: ((p_2.group_id = $26) OR (alternatives: SubPlan 16 or hashed SubPlan 17))
110.          

SubPlan (for Index Scan)

111. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.72..119.44 rows=1 width=0) (never executed)

112. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_15 (cost=0.30..8.32 rows=1 width=4) (never executed)

  • Output: insecure_temp_user_group_15.organization_id, insecure_temp_user_group_15.user_id, insecure_temp_user_group_15.group_id
  • Index Cond: ((insecure_temp_user_group_15.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_15.user_id = (current_setting('lanetix.user_id'::text))::integer))
  • Heap Fetches: 0
113. 0.000 0.000 ↓ 0.0 0

Index Scan using organization_id_descendent_id on records.insecure_temp_group_closure insecure_temp_group_closure_4 (cost=0.42..111.11 rows=1 width=4) (never executed)

  • Output: insecure_temp_group_closure_4.organization_id, insecure_temp_group_closure_4.ancestor_id, insecure_temp_group_closure_4.descendent_id
  • Index Cond: ((insecure_temp_group_closure_4.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_group_closure_4.descendent_id = insecure_temp_user_group_15.group_id))
  • Filter: (insecure_temp_group_closure_4.ancestor_id = p_2.group_id)
114. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.72..119.70 rows=222 width=4) (never executed)

  • Output: insecure_temp_group_closure_5.ancestor_id
115. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_user_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_16 (cost=0.30..8.32 rows=1 width=4) (never executed)

  • Output: insecure_temp_user_group_16.organization_id, insecure_temp_user_group_16.user_id, insecure_temp_user_group_16.group_id
  • Index Cond: ((insecure_temp_user_group_16.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_16.user_id = (current_setting('lanetix.user_id'::text))::integer))
  • Heap Fetches: 0
116. 0.000 0.000 ↓ 0.0 0

Index Scan using organization_id_descendent_id on records.insecure_temp_group_closure insecure_temp_group_closure_5 (cost=0.42..111.02 rows=36 width=8) (never executed)

  • Output: insecure_temp_group_closure_5.organization_id, insecure_temp_group_closure_5.ancestor_id, insecure_temp_group_closure_5.descendent_id
  • Index Cond: ((insecure_temp_group_closure_5.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_group_closure_5.descendent_id = insecure_temp_user_group_16.group_id))
117. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_group_pkey on records.insecure_temp_group g_5 (cost=0.29..8.31 rows=1 width=8) (never executed)

  • Output: g_5.organization_id, g_5.id, g_5.status, g_5.name, g_5.description, g_5.reference_metadata
  • Index Cond: ((g_5.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (g_5.id = p_2.group_id))
118. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.58..4.51 rows=1 width=8) (never executed)

  • Output: insecure_temp_user_group_17.group_id, (CASE WHEN NULLIF((NOT users_5.active), false) THEN 'archived'::group_status ELSE NULL::group_status END)
119. 0.000 0.000 ↓ 0.0 0

Index Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_17 (cost=0.29..0.40 rows=1 width=8) (never executed)

  • Output: insecure_temp_user_group_17.organization_id, insecure_temp_user_group_17.user_id, insecure_temp_user_group_17.group_id
  • Index Cond: ((insecure_temp_user_group_17.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_17.group_id = g_5.id))
120. 0.000 0.000 ↓ 0.0 0

Index Scan using users_pkey on public.users users_5 (cost=0.29..4.10 rows=1 width=8) (never executed)

  • Output: users_5.id, CASE WHEN NULLIF((NOT users_5.active), false) THEN 'archived'::group_status ELSE NULL::group_status END
  • Index Cond: (users_5.id = insecure_temp_user_group_17.user_id)
  • Filter: (users_5.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
121.          

SubPlan (for Nested Loop Left Join)

122. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_12 (cost=0.29..8.31 rows=1 width=0) (never executed)

  • Index Cond: ((insecure_temp_user_group_12.organization_id = (current_setting('lanetix.organization_id'::text))::integer) AND (insecure_temp_user_group_12.group_id = g_5.id))
  • Heap Fetches: 0
123. 0.000 0.000 ↓ 0.0 0

Index Only Scan using insecure_temp_user_group_organization_id_group_id_idx on records.insecure_temp_user_group insecure_temp_user_group_13 (cost=0.29..111.03 rows=2,672 width=4) (never executed)

  • Output: insecure_temp_user_group_13.group_id
  • Index Cond: (insecure_temp_user_group_13.organization_id = (current_setting('lanetix.organization_id'::text))::integer)
  • Heap Fetches: 0
Planning time : 26.389 ms
Execution time : 4,246.926 ms