explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 6HlkZ

Settings
# exclusive inclusive rows x rows loops node
1. 207.872 4,297.867 ↓ 43,710.0 43,710 1

Sort (cost=757,395.49..757,395.49 rows=1 width=259) (actual time=4,282.788..4,297.867 rows=43,710 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" <> 0) 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: 8,736kB
2. 121.256 4,089.995 ↓ 43,710.0 43,710 1

Nested Loop Left Join (cost=729,062.78..757,395.48 rows=1 width=259) (actual time=2,520.276..4,089.995 rows=43,710 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" <> 0) 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. 86.420 3,662.769 ↓ 43,710.0 43,710 1

Nested Loop Semi Join (cost=729,062.07..746,057.24 rows=1 width=241) (actual time=2,520.242..3,662.769 rows=43,710 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. 42.830 3,445.219 ↓ 43,710.0 43,710 1

Nested Loop (cost=729,061.78..734,727.51 rows=1 width=355) (actual time=2,520.220..3,445.219 rows=43,710 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. 83.747 2,877.869 ↓ 43,710.0 43,710 1

Nested Loop (cost=729,053.46..734,719.16 rows=1 width=351) (actual time=2,520.176..2,877.869 rows=43,710 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. 81.634 2,661.717 ↓ 44,135.0 44,135 1

Merge Join (cost=729,053.17..729,054.15 rows=1 width=255) (actual time=2,518.128..2,661.717 rows=44,135 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. 527.344 641.315 ↓ 1,532.4 82,752 1

Sort (cost=652.04..652.18 rows=54 width=152) (actual time=600.565..641.315 rows=82,752 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: 14,088kB
8. 49.146 113.971 ↓ 1,532.5 82,753 1

Nested Loop (cost=264.78..650.49 rows=54 width=152) (actual time=0.327..113.971 rows=82,753 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.123 0.483 ↓ 1.8 53 1

Merge Join (cost=264.35..265.31 rows=29 width=92) (actual time=0.306..0.483 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.071 0.140 ↑ 1.1 53 1

Sort (cost=109.50..109.64 rows=57 width=67) (actual time=0.121..0.140 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.042 0.069 ↑ 1.1 53 1

Bitmap Heap Scan on records.insecure_stage_templates (cost=5.01..107.84 rows=57 width=67) (actual time=0.032..0.069 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.027 0.027 ↑ 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.026..0.027 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.153 0.220 ↓ 1.5 113 1

Sort (cost=154.85..155.04 rows=76 width=25) (actual time=0.182..0.220 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.067 0.067 ↑ 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.010..0.067 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. 64.342 64.342 ↓ 1,561.0 1,561 53

Index Scan using insecure_workflows_pkey on records.insecure_workflows w (cost=0.43..13.27 rows=1 width=60) (actual time=0.008..1.214 rows=1,561 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. 272.870 1,938.768 ↓ 44,135.0 44,135 1

Sort (cost=728,401.13..728,401.13 rows=1 width=107) (actual time=1,917.557..1,938.768 rows=44,135 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: 5,560kB
17. 19.305 1,665.898 ↓ 44,135.0 44,135 1

Subquery Scan on e (cost=726,898.06..728,401.12 rows=1 width=107) (actual time=1,568.470..1,665.898 rows=44,135 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. 59.469 1,646.593 ↓ 44,135.0 44,135 1

Hash Right Join (cost=726,898.06..728,401.11 rows=1 width=107) (actual time=1,568.468..1,646.593 rows=44,135 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. 56.605 1,189.137 ↓ 1.1 44,135 1

WindowAgg (cost=712,006.71..713,250.60 rows=41,463 width=130) (actual time=1,116.042..1,189.137 rows=44,135 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. 162.497 1,132.532 ↓ 1.1 44,135 1

Sort (cost=712,006.71..712,110.36 rows=41,463 width=89) (actual time=1,116.029..1,132.532 rows=44,135 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: 4,528kB
22. 25.825 970.035 ↓ 1.1 44,135 1

Nested Loop (cost=17.48..708,826.59 rows=41,463 width=89) (actual time=0.055..970.035 rows=44,135 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. 37.395 502.860 ↓ 1.1 44,135 1

Nested Loop (cost=9.02..356,805.72 rows=41,463 width=81) (actual time=0.040..502.860 rows=44,135 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. 24.115 24.115 ↓ 1.1 44,135 1

Index Only Scan using insecure_transition_events_pkey on records.insecure_transition_events insecure_transition_events_1 (cost=0.56..4,784.85 rows=41,463 width=73) (actual time=0.009..24.115 rows=44,135 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: 8,912
25. 88.270 441.350 ↑ 1.0 1 44,135

Limit (cost=8.46..8.47 rows=1 width=8) (actual time=0.009..0.010 rows=1 loops=44,135)

  • Output: insecure_transition_events_2."timestamp
26. 88.270 353.080 ↑ 1.0 1 44,135

Sort (cost=8.46..8.47 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=44,135)

  • Output: insecure_transition_events_2."timestamp
  • Sort Key: insecure_transition_events_2."timestamp
  • Sort Method: quicksort Memory: 25kB
27. 264.810 264.810 ↓ 4.0 4 44,135

Index Scan using insecure_transition_events_idx1 on records.insecure_transition_events insecure_transition_events_2 (cost=0.43..8.46 rows=1 width=8) (actual time=0.004..0.006 rows=4 loops=44,135)

  • 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_1.record_type = insecure_transition_events_2.record_type) AND (insecure_transition_events_1.record_id = insecure_transition_events_2.record_id) AND (insecure_transition_events_1.workflow_template_api_name = insecure_transition_events_2.workflow_template_api_name))
28. 88.270 441.350 ↑ 1.0 1 44,135

Limit (cost=8.46..8.47 rows=1 width=8) (actual time=0.009..0.010 rows=1 loops=44,135)

  • Output: insecure_transition_events_3."timestamp
29. 132.405 353.080 ↑ 1.0 1 44,135

Sort (cost=8.46..8.47 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=44,135)

  • Output: insecure_transition_events_3."timestamp
  • Sort Key: insecure_transition_events_3."timestamp" DESC
  • Sort Method: quicksort Memory: 25kB
30. 220.675 220.675 ↓ 4.0 4 44,135

Index Scan using insecure_transition_events_idx1 on records.insecure_transition_events insecure_transition_events_3 (cost=0.43..8.46 rows=1 width=8) (actual time=0.004..0.005 rows=4 loops=44,135)

  • 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_1.record_type = insecure_transition_events_3.record_type) AND (insecure_transition_events_1.record_id = insecure_transition_events_3.record_id) AND (insecure_transition_events_1.workflow_template_api_name = insecure_transition_events_3.workflow_template_api_name))
31. 18.726 18.726 ↓ 1.1 44,135 1

CTE Scan on e en (cost=0.00..829.26 rows=41,463 width=84) (actual time=0.017..18.726 rows=44,135 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. 33.050 1,568.398 ↓ 44,135.0 44,135 1

Hash (cost=13,647.44..13,647.44 rows=1 width=175) (actual time=1,568.398..1,568.398 rows=44,135 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: 65,536 (originally 1024) Batches: 2 (originally 1) Memory Usage: 6,479kB
33. 71.059 1,535.348 ↓ 44,135.0 44,135 1

Merge Join (cost=7,411.93..13,647.44 rows=1 width=175) (actual time=1,407.000..1,535.348 rows=44,135 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. 24.168 24.168 ↓ 1.1 44,135 1

Index Only Scan using insecure_transition_events_pkey on records.insecure_transition_events (cost=0.56..4,784.85 rows=41,463 width=73) (actual time=0.029..24.168 rows=44,135 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: 8,912
35. 18.699 1,440.121 ↓ 1.1 44,135 1

Materialize (cost=7,411.38..7,618.69 rows=41,463 width=166) (actual time=1,406.965..1,440.121 rows=44,135 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. 169.035 1,421.422 ↓ 1.1 44,135 1

Sort (cost=7,411.38..7,515.03 rows=41,463 width=166) (actual time=1,406.963..1,421.422 rows=44,135 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: 5,224kB
37. 1,252.387 1,252.387 ↓ 1.1 44,135 1

CTE Scan on e e_1 (cost=0.00..829.26 rows=41,463 width=166) (actual time=1,116.047..1,252.387 rows=44,135 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. 132.405 132.405 ↑ 1.0 1 44,135

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.002..0.003 rows=1 loops=44,135)

  • 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,299.14 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..137.55 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..129.23 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..120.90 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..112.57 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..121.16 rows=202 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..112.48 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.420 524.520 ↑ 1.0 1 43,710

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

  • Output: ((insecure_stage_templates_1."order" + 1))
66. 174.840 437.100 ↑ 1.0 1 43,710

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

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

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,710)

  • 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. 131.130 131.130 ↑ 1.0 1 43,710

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,710)

  • 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,299.15 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..137.56 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..129.23 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..120.90 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..112.57 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..121.16 rows=202 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..112.48 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. 70.158 305.970 ↓ 0.0 0 43,710

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

  • Output: w_1.stage_api_name, w_1.record_type, w_1.workflow_template_api_name, w_1.record_id
96. 174.840 174.840 ↓ 0.0 0 43,710

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,710)

  • 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.972 60.972 ↑ 1.0 1 20,324

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,324)

  • 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,299.15 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..137.56 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..129.23 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..120.90 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..112.57 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..121.16 rows=202 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..112.48 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 : 25.854 ms
Execution time : 4,313.931 ms