explain.depesz.com

PostgreSQL's explain analyze made readable

Result: kaJh

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 1,569.356 ↓ 5.0 20 1

Limit (cost=2,065,178.88..2,065,178.93 rows=4 width=950) (actual time=1,569.348..1,569.356 rows=20 loops=1)

2. 0.006 1,569.353 ↓ 5.0 20 1

Subquery Scan on lead_report (cost=2,065,178.88..2,065,178.93 rows=4 width=950) (actual time=1,569.347..1,569.353 rows=20 loops=1)

3. 0.000 1,569.347 ↓ 5.0 20 1

Sort (cost=2,065,178.88..2,065,178.89 rows=4 width=954) (actual time=1,569.345..1,569.347 rows=20 loops=1)

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

CTE cte_exists

5. 126.163 1,409.865 ↑ 624.4 76,859 1

Merge Join (cost=237,020.55..957,565.72 rows=47,991,917 width=4) (actual time=1,395.846..1,409.865 rows=76,859 loops=1)

  • Merge Cond: (wftlt.lead_time_id = wfelt.lead_time_id)
6. 2.841 7.513 ↑ 1.0 12,661 1

Sort (cost=1,592.32..1,624.33 rows=12,804 width=4) (actual time=6.603..7.513 rows=12,661 loops=1)

  • Sort Key: wftlt.lead_time_id
  • Sort Method: quicksort Memory: 985kB
7. 4.672 4.672 ↑ 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.015..4.672 rows=12,804 loops=1)

  • Filter: (lead_time_type = 3)
  • Rows Removed by Filter: 9,593
8. 107.523 1,276.189 ↓ 4.6 1,109,478 1

Materialize (cost=235,428.23..236,633.48 rows=241,051 width=8) (actual time=1,064.749..1,276.189 rows=1,109,478 loops=1)

9. 441.731 1,168.666 ↓ 4.3 1,032,902 1

Sort (cost=235,428.23..236,030.85 rows=241,051 width=8) (actual time=1,064.744..1,168.666 rows=1,032,902 loops=1)

  • Sort Key: wfelt.lead_time_id
  • Sort Method: external sort Disk: 18,200kB
10. 403.724 726.935 ↓ 4.3 1,032,902 1

Hash Join (cost=20,306.25..210,582.50 rows=241,051 width=8) (actual time=78.123..726.935 rows=1,032,902 loops=1)

  • Hash Cond: (wfelt.entity_id = action_1.id)
11. 247.852 319.483 ↓ 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=74.382..319.483 rows=1,079,746 loops=1)

  • Recheck Cond: (entity_type_id = 18)
  • Heap Blocks: exact=15,797
12. 71.631 71.631 ↓ 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=71.631..71.631 rows=1,079,747 loops=1)

  • Index Cond: (entity_type_id = 18)
13. 0.617 3.728 ↓ 1.0 4,563 1

Hash (cost=761.69..761.69 rows=4,554 width=4) (actual time=3.728..3.728 rows=4,563 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 225kB
14. 3.111 3.111 ↓ 1.0 4,563 1

Seq Scan on action_item_mgmt action_1 (cost=0.00..761.69 rows=4,554 width=4) (actual time=0.014..3.111 rows=4,563 loops=1)

  • Filter: ((NOT deleted) AND (client_id = 1,005))
  • Rows Removed by Filter: 382
15.          

Initplan (for Sort)

16. 2.327 121.137 ↓ 79.0 4,264 1

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

  • Group Key: edl.entity_id
17.          

CTE user_data_filter

18. 2.635 2.979 ↑ 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.380..2.979 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.344 0.344 ↑ 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.344..0.344 rows=7,189 loops=1)

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

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

21. 3.815 26.443 ↓ 163.7 8,674 1

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

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

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

  • Sort Key: edl.ancestor_id, edl.ancestor_type_id
  • Sort Method: quicksort Memory: 1,723kB
23. 4.997 6.670 ↑ 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.809..6.670 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.673 1.673 ↑ 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.672..1.673 rows=20,609 loops=1)

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

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

  • Sort Key: da.entity_id, da.entity_type_id
  • Sort Method: quicksort Memory: 529kB
26. 5.945 5.945 ↓ 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.382..5.945 rows=7,183 loops=1)

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

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

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

Merge Join (cost=12,039.14..12,637.23 rows=190 width=40) (actual time=91.869..91.869 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. 53.778 91.354 ↑ 75,812.0 1 1

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

  • Sort Key: edl_1.ancestor_id, edl_1.ancestor_type_id
  • Sort Method: external merge Disk: 1,968kB
30. 37.576 37.576 ↓ 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.020..37.576 rows=77,261 loops=1)

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

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

  • Sort Key: da_1.entity_id, da_1.entity_type_id
  • Sort Method: quicksort Memory: 25kB
32. 0.502 0.502 ↓ 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.502..0.502 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.406 1,569.235 ↓ 29.5 118 1

Nested Loop Left Join (cost=1,079,864.30..1,079,993.86 rows=4 width=954) (actual time=1,563.684..1,569.235 rows=118 loops=1)

35. 0.424 1,568.711 ↓ 29.5 118 1

Nested Loop Left Join (cost=1,079,864.01..1,079,960.47 rows=4 width=988) (actual time=1,563.674..1,568.711 rows=118 loops=1)

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

Nested Loop Left Join (cost=1,079,864.01..1,079,955.92 rows=4 width=476) (actual time=1,563.646..1,568.051 rows=118 loops=1)

37. 0.137 1,567.783 ↓ 29.5 118 1

Nested Loop Left Join (cost=1,079,863.73..1,079,924.49 rows=4 width=462) (actual time=1,563.638..1,567.783 rows=118 loops=1)

38. 0.063 1,567.410 ↓ 29.5 118 1

Hash Left Join (cost=1,079,863.46..1,079,900.20 rows=4 width=447) (actual time=1,563.619..1,567.410 rows=118 loops=1)

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

Hash Join (cost=1,079,861.53..1,079,898.27 rows=4 width=177) (actual time=1,563.575..1,567.316 rows=118 loops=1)

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

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

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

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

  • Index Cond: (id = ANY ($4))
42. 0.022 1,438.045 ↑ 1.5 133 1

Hash (cost=1,079,820.13..1,079,820.13 rows=200 width=4) (actual time=1,438.045..1,438.045 rows=133 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 13kB
43. 12.254 1,438.023 ↑ 1.5 133 1

HashAggregate (cost=1,079,818.13..1,079,820.13 rows=200 width=4) (actual time=1,438.005..1,438.023 rows=133 loops=1)

  • Group Key: cte_exists.id
44. 1,425.769 1,425.769 ↑ 624.4 76,859 1

CTE Scan on cte_exists (cost=0.00..959,838.34 rows=47,991,917 width=4) (actual time=1,395.849..1,425.769 rows=76,859 loops=1)

45. 0.008 0.031 ↑ 1.0 41 1

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

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

Seq Scan on time_zone tz (cost=0.00..1.41 rows=41 width=278) (actual time=0.017..0.023 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.236 0.236 ↑ 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.002..0.002 rows=1 loops=118)

  • Index Cond: (action.status_id = id)
49. 0.215 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.021 0.021 ↑ 1.0 49 1

Seq Scan on tier (cost=0.00..1.49 rows=49 width=520) (actual time=0.010..0.021 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 : 4.180 ms
Execution time : 1,573.716 ms