explain.depesz.com

PostgreSQL's explain analyze made readable

Result: TKAx

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 1,491.601 ↓ 5.0 20 1

Limit (cost=2,218,020.01..2,218,020.06 rows=4 width=950) (actual time=1,491.594..1,491.601 rows=20 loops=1)

2. 0.006 1,491.599 ↓ 5.0 20 1

Subquery Scan on lead_report (cost=2,218,020.01..2,218,020.06 rows=4 width=950) (actual time=1,491.593..1,491.599 rows=20 loops=1)

3. 0.000 1,491.593 ↓ 5.0 20 1

Sort (cost=2,218,020.01..2,218,020.02 rows=4 width=954) (actual time=1,491.591..1,491.593 rows=20 loops=1)

  • Sort Key: action.client_entity_seq_id DESC
  • Sort Method: quicksort Memory: 80kB
4.          

CTE cte_exists

5. 106.646 1,323.895 ↑ 670.1 77,609 1

Merge Join (cost=239,243.70..1,020,066.35 rows=52,007,051 width=4) (actual time=1,303.541..1,323.895 rows=77,609 loops=1)

  • Merge Cond: (wftlt.lead_time_id = wfelt.lead_time_id)
6. 2.679 6.943 ↑ 1.0 12,792 1

Sort (cost=1,592.32..1,624.33 rows=12,804 width=4) (actual time=6.067..6.943 rows=12,792 loops=1)

  • Sort Key: wftlt.lead_time_id
  • Sort Method: quicksort Memory: 985kB
7. 4.264 4.264 ↑ 1.0 12,804 1

Seq Scan on work_flow_task_lead_time wftlt (cost=0.00..718.81 rows=12,804 width=4) (actual time=0.016..4.264 rows=12,804 loops=1)

  • Filter: (lead_time_type = 3)
  • Rows Removed by Filter: 9,593
8. 90.481 1,210.306 ↓ 4.4 1,157,035 1

Materialize (cost=237,651.37..238,957.46 rows=261,218 width=8) (actual time=1,026.833..1,210.306 rows=1,157,035 loops=1)

9. 454.348 1,119.825 ↓ 4.1 1,079,746 1

Sort (cost=237,651.37..238,304.42 rows=261,218 width=8) (actual time=1,026.830..1,119.825 rows=1,079,746 loops=1)

  • Sort Key: wfelt.lead_time_id
  • Sort Method: external merge Disk: 19,024kB
10. 360.627 665.477 ↓ 4.1 1,079,746 1

Hash Join (cost=20,298.67..210,574.92 rows=261,218 width=8) (actual time=74.726..665.477 rows=1,079,746 loops=1)

  • Hash Cond: (wfelt.entity_id = action_1.id)
11. 232.815 293.847 ↓ 1.0 1,079,746 1

Bitmap Heap Scan on work_flow_entity_lead_time wfelt (cost=19,487.64..207,028.15 rows=1,041,961 width=8) (actual time=63.712..293.847 rows=1,079,746 loops=1)

  • Recheck Cond: (entity_type_id = 18)
  • Heap Blocks: exact=15,797
12. 61.032 61.032 ↓ 1.0 1,079,747 1

Bitmap Index Scan on idx_work_flow_entity_lead_time_entity (cost=0.00..19,227.15 rows=1,041,961 width=0) (actual time=61.032..61.032 rows=1,079,747 loops=1)

  • Index Cond: (entity_type_id = 18)
13. 0.640 11.003 ↓ 1.0 4,945 1

Hash (cost=749.35..749.35 rows=4,935 width=4) (actual time=11.002..11.003 rows=4,945 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 238kB
14. 10.363 10.363 ↓ 1.0 4,945 1

Seq Scan on action_item_mgmt action_1 (cost=0.00..749.35 rows=4,935 width=4) (actual time=0.007..10.363 rows=4,945 loops=1)

  • Filter: (NOT deleted)
15.          

Initplan (for Sort)

16. 2.777 129.803 ↓ 79.0 4,264 1

HashAggregate (cost=27,618.71..27,619.25 rows=54 width=4) (actual time=129.251..129.803 rows=4,264 loops=1)

  • Group Key: edl.entity_id
17.          

CTE user_data_filter

18. 2.305 3.119 ↑ 1.0 7,183 1

Bitmap Heap Scan on user_data_access (cost=141.52..9,939.21 rows=7,359 width=23) (actual time=0.844..3.119 rows=7,183 loops=1)

  • Recheck Cond: (user_id = 2,649)
  • Filter: (NOT deleted)
  • Rows Removed by Filter: 5
  • Heap Blocks: exact=223
19. 0.814 0.814 ↑ 1.0 7,189 1

Bitmap Index Scan on idx_user_data_access_user_id (cost=0.00..139.68 rows=7,367 width=0) (actual time=0.814..0.814 rows=7,189 loops=1)

  • Index Cond: (user_id = 2,649)
20. 0.557 127.026 ↓ 160.6 8,674 1

Append (cost=4,729.83..17,679.37 rows=54 width=4) (actual time=30.576..127.026 rows=8,674 loops=1)

21. 4.490 37.730 ↓ 163.7 8,674 1

Merge Join (cost=4,729.83..4,918.13 rows=53 width=4) (actual time=30.576..37.730 rows=8,674 loops=1)

  • Merge Cond: ((edl.ancestor_id = da.entity_id) AND (edl.ancestor_type_id = da.entity_type_id))
22. 9.662 23.108 ↑ 1.0 20,361 1

Sort (cost=4,364.69..4,418.08 rows=21,356 width=12) (actual time=21.470..23.108 rows=20,361 loops=1)

  • Sort Key: edl.ancestor_id, edl.ancestor_type_id
  • Sort Method: quicksort Memory: 1,723kB
23. 11.629 13.446 ↑ 1.0 20,361 1

Bitmap Heap Scan on entity_data_link edl (cost=407.45..2,828.94 rows=21,356 width=12) (actual time=1.988..13.446 rows=20,361 loops=1)

  • Recheck Cond: (entity_type_id = 18)
  • Filter: (NOT deleted)
  • Rows Removed by Filter: 243
  • Heap Blocks: exact=957
24. 1.817 1.817 ↑ 1.0 20,609 1

Bitmap Index Scan on idx_entity_data_link_entity_type_id_entity_id (cost=0.00..402.12 rows=21,559 width=0) (actual time=1.817..1.817 rows=20,609 loops=1)

  • Index Cond: (entity_type_id = 18)
25. 4.063 10.132 ↓ 4.2 15,582 1

Sort (cost=365.14..374.34 rows=3,680 width=8) (actual time=9.091..10.132 rows=15,582 loops=1)

  • Sort Key: da.entity_id, da.entity_type_id
  • Sort Method: quicksort Memory: 529kB
26. 6.069 6.069 ↓ 2.0 7,183 1

CTE Scan on user_data_filter da (cost=0.00..147.18 rows=3,680 width=8) (actual time=0.847..6.069 rows=7,183 loops=1)

  • Filter: self_access
27. 0.001 88.739 ↓ 0.0 0 1

Nested Loop (cost=12,039.56..12,760.70 rows=1 width=4) (actual time=88.739..88.739 rows=0 loops=1)

  • Join Filter: (edc.ancestor_type_id = ANY (da_1.access_type_ids))
28. 0.002 88.738 ↓ 0.0 0 1

Merge Join (cost=12,039.14..12,637.23 rows=190 width=40) (actual time=88.738..88.738 rows=0 loops=1)

  • Merge Cond: ((edl_1.ancestor_id = da_1.entity_id) AND (edl_1.ancestor_type_id = da_1.entity_type_id))
29. 49.855 88.230 ↑ 75,812.0 1 1

Sort (cost=11,674.01..11,863.54 rows=75,812 width=16) (actual time=88.230..88.230 rows=1 loops=1)

  • Sort Key: edl_1.ancestor_id, edl_1.ancestor_type_id
  • Sort Method: external merge Disk: 1,968kB
30. 38.375 38.375 ↓ 1.0 77,261 1

Seq Scan on entity_data_link edl_1 (cost=0.00..5,529.39 rows=75,812 width=16) (actual time=0.021..38.375 rows=77,261 loops=1)

  • Filter: (parent AND (NOT deleted))
  • Rows Removed by Filter: 260,572
31. 0.008 0.506 ↓ 0.0 0 1

Sort (cost=365.14..374.34 rows=3,680 width=40) (actual time=0.506..0.506 rows=0 loops=1)

  • Sort Key: da_1.entity_id, da_1.entity_type_id
  • Sort Method: quicksort Memory: 25kB
32. 0.498 0.498 ↓ 0.0 0 1

CTE Scan on user_data_filter da_1 (cost=0.00..147.18 rows=3,680 width=40) (actual time=0.498..0.498 rows=0 loops=1)

  • Filter: (NOT self_access)
  • Rows Removed by Filter: 7,183
33. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_entity_data_link_entity_type_id_ancestor_type_id_ancestor_i on entity_data_link edc (cost=0.42..0.63 rows=1 width=12) (never executed)

  • Index Cond: ((entity_type_id = 18) AND (ancestor_type_id = edl_1.entity_type_id) AND (ancestor_id = edl_1.entity_id))
  • Filter: (NOT deleted)
34. 0.264 1,491.514 ↓ 29.5 118 1

Nested Loop Left Join (cost=1,170,204.81..1,170,334.38 rows=4 width=954) (actual time=1,488.081..1,491.514 rows=118 loops=1)

35. 0.364 1,491.132 ↓ 29.5 118 1

Nested Loop Left Join (cost=1,170,204.53..1,170,300.99 rows=4 width=988) (actual time=1,488.074..1,491.132 rows=118 loops=1)

  • Join Filter: (action.tier_id = tier.id)
  • Rows Removed by Join Filter: 4,810
36. 0.086 1,490.532 ↓ 29.5 118 1

Nested Loop Left Join (cost=1,170,204.53..1,170,296.44 rows=4 width=476) (actual time=1,488.046..1,490.532 rows=118 loops=1)

37. 0.000 1,490.328 ↓ 29.5 118 1

Nested Loop Left Join (cost=1,170,204.25..1,170,265.01 rows=4 width=462) (actual time=1,488.040..1,490.328 rows=118 loops=1)

38. 0.045 1,490.093 ↓ 29.5 118 1

Hash Left Join (cost=1,170,203.97..1,170,240.72 rows=4 width=447) (actual time=1,488.028..1,490.093 rows=118 loops=1)

  • Hash Cond: (action.time_zone_id = tz.id)
39. 0.401 1,490.020 ↓ 29.5 118 1

Hash Join (cost=1,170,202.05..1,170,238.78 rows=4 width=177) (actual time=1,487.989..1,490.020 rows=118 loops=1)

  • Hash Cond: (action.id = cte_exists.id)
40. 1.714 135.980 ↓ 473.8 4,264 1

Bitmap Heap Scan on action_item_mgmt action (cost=38.90..75.57 rows=9 width=177) (actual time=134.325..135.980 rows=4,264 loops=1)

  • Recheck Cond: (id = ANY ($4))
  • Filter: ((NOT deleted) AND (client_id = 1,005))
  • Heap Blocks: exact=385
41. 134.266 134.266 ↓ 426.4 4,264 1

Bitmap Index Scan on pk_action_item_mgmt (cost=0.00..38.90 rows=10 width=0) (actual time=134.266..134.266 rows=4,264 loops=1)

  • Index Cond: (id = ANY ($4))
42. 0.024 1,353.639 ↑ 1.3 157 1

Hash (cost=1,170,160.65..1,170,160.65 rows=200 width=4) (actual time=1,353.639..1,353.639 rows=157 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 14kB
43. 12.920 1,353.615 ↑ 1.3 157 1

HashAggregate (cost=1,170,158.65..1,170,160.65 rows=200 width=4) (actual time=1,353.596..1,353.615 rows=157 loops=1)

  • Group Key: cte_exists.id
44. 1,340.695 1,340.695 ↑ 670.1 77,609 1

CTE Scan on cte_exists (cost=0.00..1,040,141.02 rows=52,007,051 width=4) (actual time=1,303.543..1,340.695 rows=77,609 loops=1)

45. 0.008 0.028 ↑ 1.0 41 1

Hash (cost=1.41..1.41 rows=41 width=278) (actual time=0.028..0.028 rows=41 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
46. 0.020 0.020 ↑ 1.0 41 1

Seq Scan on time_zone tz (cost=0.00..1.41 rows=41 width=278) (actual time=0.015..0.020 rows=41 loops=1)

47. 0.236 0.236 ↑ 1.0 1 118

Index Scan using pk_relation on relation re (cost=0.28..6.07 rows=1 width=19) (actual time=0.002..0.002 rows=1 loops=118)

  • Index Cond: (action.relation_id = id)
48. 0.118 0.118 ↑ 1.0 1 118

Index Scan using pk_work_flow_status on work_flow_status ets (cost=0.28..7.86 rows=1 width=22) (actual time=0.001..0.001 rows=1 loops=118)

  • Index Cond: (action.status_id = id)
49. 0.223 0.236 ↑ 1.2 42 118

Materialize (cost=0.00..1.73 rows=49 width=520) (actual time=0.000..0.002 rows=42 loops=118)

50. 0.013 0.013 ↑ 1.0 49 1

Seq Scan on tier (cost=0.00..1.49 rows=49 width=520) (actual time=0.008..0.013 rows=49 loops=1)

51. 0.118 0.118 ↓ 0.0 0 118

Index Scan using pk_governance_body_child on governance_body_child gbc (cost=0.29..8.30 rows=1 width=26) (actual time=0.001..0.001 rows=0 loops=118)

  • Index Cond: (action.governance_body_child_id = id)
Planning time : 6.006 ms
Execution time : 1,496.058 ms