explain.depesz.com

PostgreSQL's explain analyze made readable

Result: NWXs

Settings
# exclusive inclusive rows x rows loops node
1. 0.006 15,079.604 ↓ 2.0 20 1

Subquery Scan on relation_list (cost=1,684,628.80..1,684,628.93 rows=10 width=4) (actual time=15,079.574..15,079.604 rows=20 loops=1)

2. 0.024 15,079.598 ↓ 2.0 20 1

Limit (cost=1,684,628.80..1,684,628.83 rows=10 width=1,315) (actual time=15,079.573..15,079.598 rows=20 loops=1)

3. 138.088 15,079.574 ↓ 2.0 20 1

Sort (cost=1,684,628.80..1,684,628.83 rows=10 width=1,315) (actual time=15,079.572..15,079.574 rows=20 loops=1)

  • Sort Key: relation_grouped.id DESC
  • Sort Method: top-N heapsort Memory: 26kB
4. 168.927 14,941.486 ↓ 34,115.7 341,157 1

Subquery Scan on relation_grouped (cost=1,684,618.39..1,684,628.64 rows=10 width=1,315) (actual time=8,845.602..14,941.486 rows=341,157 loops=1)

5. 174.105 14,772.559 ↓ 34,115.7 341,157 1

Group (cost=1,684,618.39..1,684,628.54 rows=10 width=801) (actual time=8,845.599..14,772.559 rows=341,157 loops=1)

  • Group Key: r.id, tz.time_zone, crp.color, (max(au_1.date_created)), (max(au.date_created))
6.          

Initplan (for Group)

7. 246.464 5,658.226 ↓ 10.8 341,157 1

HashAggregate (cost=1,398,901.43..1,399,216.45 rows=31,502 width=4) (actual time=5,554.010..5,658.226 rows=341,157 loops=1)

  • Group Key: edl.entity_id
8.          

CTE user_data_filter

9. 42.004 48.305 ↓ 1.0 155,719 1

Bitmap Heap Scan on user_data_access (cost=3,406.92..42,415.01 rows=148,967 width=48) (actual time=6.458..48.305 rows=155,719 loops=1)

  • Recheck Cond: (user_id = 1,199)
  • Filter: (NOT deleted)
  • Heap Blocks: exact=1,509
10. 6.301 6.301 ↓ 1.0 155,719 1

Bitmap Index Scan on idx_user_data_access_user_id (cost=0.00..3,369.68 rows=148,967 width=0) (actual time=6.301..6.301 rows=155,719 loops=1)

  • Index Cond: (user_id = 1,199)
11. 82.479 5,411.762 ↓ 11.0 346,244 1

Append (cost=345,129.52..1,356,407.67 rows=31,502 width=4) (actual time=949.682..5,411.762 rows=346,244 loops=1)

12. 299.636 1,532.745 ↓ 12.2 346,244 1

Merge Join (cost=345,129.52..353,362.68 rows=28,316 width=4) (actual time=949.681..1,532.745 rows=346,244 loops=1)

  • Merge Cond: ((edl.ancestor_id = da.entity_id) AND (edl.ancestor_type_id = da.entity_type_id))
13. 559.933 939.546 ↓ 1.0 1,023,780 1

Sort (cost=336,122.69..338,586.48 rows=985,516 width=12) (actual time=724.361..939.546 rows=1,023,780 loops=1)

  • Sort Key: edl.ancestor_id, edl.ancestor_type_id
  • Sort Method: external merge Disk: 22,056kB
14. 379.613 379.613 ↓ 1.0 1,023,780 1

Index Scan using idx_entity_data_link_entity_type_id on entity_data_link edl (cost=0.56..221,166.51 rows=985,516 width=12) (actual time=0.017..379.613 rows=1,023,780 loops=1)

  • Index Cond: (entity_type_id = 1)
  • Filter: (NOT deleted)
15. 173.003 293.563 ↓ 5.0 375,931 1

Sort (cost=9,006.82..9,193.03 rows=74,484 width=8) (actual time=225.260..293.563 rows=375,931 loops=1)

  • Sort Key: da.entity_id, da.entity_type_id
  • Sort Method: external sort Disk: 3,360kB
16. 120.560 120.560 ↓ 2.1 155,719 1

CTE Scan on user_data_filter da (cost=0.00..2,979.34 rows=74,484 width=8) (actual time=6.462..120.560 rows=155,719 loops=1)

  • Filter: self_access
17. 0.001 3,796.538 ↓ 0.0 0 1

Nested Loop (cost=858,607.35..1,002,572.46 rows=3,186 width=4) (actual time=3,796.538..3,796.538 rows=0 loops=1)

  • Join Filter: (edc.ancestor_type_id = ANY (da_1.access_type_ids))
18. 0.007 3,796.537 ↓ 0.0 0 1

Merge Join (cost=858,606.79..884,298.63 rows=92,239 width=40) (actual time=3,796.537..3,796.537 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))
19. 1,265.923 3,777.656 ↑ 3,210,355.0 1 1

Sort (cost=849,599.96..857,625.85 rows=3,210,355 width=16) (actual time=3,777.656..3,777.656 rows=1 loops=1)

  • Sort Key: edl_1.ancestor_id, edl_1.ancestor_type_id
  • Sort Method: external merge Disk: 84,368kB
20. 2,511.733 2,511.733 ↓ 1.0 3,312,396 1

Seq Scan on entity_data_link edl_1 (cost=0.00..447,786.06 rows=3,210,355 width=16) (actual time=0.034..2,511.733 rows=3,312,396 loops=1)

  • Filter: (parent AND (NOT deleted))
  • Rows Removed by Filter: 14,519,610
21. 0.010 18.874 ↓ 0.0 0 1

Sort (cost=9,006.82..9,193.03 rows=74,484 width=40) (actual time=18.874..18.874 rows=0 loops=1)

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

CTE Scan on user_data_filter da_1 (cost=0.00..2,979.34 rows=74,484 width=40) (actual time=18.863..18.864 rows=0 loops=1)

  • Filter: (NOT self_access)
  • Rows Removed by Filter: 155,719
23. 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.56..1.21 rows=3 width=12) (never executed)

  • Index Cond: ((entity_type_id = 1) AND (ancestor_type_id = edl_1.entity_type_id) AND (ancestor_id = edl_1.entity_id))
  • Filter: (NOT deleted)
24. 289.066 8,940.228 ↓ 34,115.7 341,157 1

Sort (cost=285,401.93..285,401.96 rows=10 width=76) (actual time=8,845.527..8,940.228 rows=341,157 loops=1)

  • Sort Key: r.id, tz.time_zone, crp.color, (max(au_1.date_created)), (max(au.date_created))
  • Sort Method: external merge Disk: 30,184kB
25. 138.035 8,651.162 ↓ 34,115.7 341,157 1

Hash Left Join (cost=276,535.34..285,401.77 rows=10 width=76) (actual time=6,120.753..8,651.162 rows=341,157 loops=1)

  • Hash Cond: (r.time_zone_id = tz.id)
26. 209.433 8,513.094 ↓ 34,115.7 341,157 1

Merge Left Join (cost=276,533.42..285,399.82 rows=10 width=64) (actual time=6,120.704..8,513.094 rows=341,157 loops=1)

  • Merge Cond: (r.id = au_1.entity_id)
27. 122.329 7,828.123 ↓ 34,115.7 341,157 1

Merge Left Join (cost=120,593.95..120,741.96 rows=10 width=56) (actual time=5,878.483..7,828.123 rows=341,157 loops=1)

  • Merge Cond: (r.id = au.entity_id)
28. 440.945 7,627.820 ↓ 34,115.7 341,157 1

Nested Loop Left Join (cost=0.85..140.28 rows=10 width=48) (actual time=5,800.504..7,627.820 rows=341,157 loops=1)

29. 6,504.561 6,504.561 ↓ 34,115.7 341,157 1

Index Scan using pk_relation on relation r (cost=0.42..55.63 rows=10 width=48) (actual time=5,800.482..6,504.561 rows=341,157 loops=1)

  • Index Cond: (id = ANY ($3))
  • Filter: ((NOT deleted) AND (client_id = 1,007))
30. 682.314 682.314 ↑ 1.0 1 341,157

Index Scan using idx_composite_rating_performance_supid_cltid_chart_id on composite_rating_performance crp (cost=0.43..8.46 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=341,157)

  • Index Cond: ((supplier_id = r.id) AND (client_id = r.client_id) AND (client_id = 1,007) AND (chart_id = 2))
31. 0.046 77.974 ↑ 3.4 84 1

GroupAggregate (cost=120,593.10..120,598.09 rows=285 width=12) (actual time=77.919..77.974 rows=84 loops=1)

  • Group Key: au.entity_id
32. 0.055 77.928 ↑ 3.1 91 1

Sort (cost=120,593.10..120,593.81 rows=285 width=12) (actual time=77.911..77.928 rows=91 loops=1)

  • Sort Key: au.entity_id
  • Sort Method: quicksort Memory: 29kB
33. 63.421 77.873 ↑ 3.1 91 1

Bitmap Heap Scan on other_audit_log au (cost=6,269.40..120,581.48 rows=285 width=12) (actual time=15.465..77.873 rows=91 loops=1)

  • Recheck Cond: (entity_type_id = 1)
  • Filter: ((work_flow_status_id = 5) OR (action_id = 9))
  • Rows Removed by Filter: 341,405
  • Heap Blocks: exact=7,791
34. 14.452 14.452 ↓ 1.0 341,496 1

Bitmap Index Scan on idx_other_audit_log_entity_type_id_entity_id (cost=0.00..6,269.32 rows=339,319 width=0) (actual time=14.452..14.452 rows=341,496 loops=1)

  • Index Cond: (entity_type_id = 1)
35. 154.841 475.538 ↓ 1.2 341,263 1

GroupAggregate (cost=155,939.47..161,228.09 rows=274,373 width=12) (actual time=242.065..475.538 rows=341,263 loops=1)

  • Group Key: au_1.entity_id
36. 206.358 320.697 ↓ 1.0 341,496 1

Sort (cost=155,939.47..156,787.76 rows=339,319 width=12) (actual time=242.052..320.697 rows=341,496 loops=1)

  • Sort Key: au_1.entity_id
  • Sort Method: external merge Disk: 8,704kB
37. 99.817 114.339 ↓ 1.0 341,496 1

Bitmap Heap Scan on other_audit_log au_1 (cost=6,354.15..118,969.64 rows=339,319 width=12) (actual time=15.532..114.339 rows=341,496 loops=1)

  • Recheck Cond: (entity_type_id = 1)
  • Heap Blocks: exact=7,791
38. 14.522 14.522 ↓ 1.0 341,496 1

Bitmap Index Scan on idx_other_audit_log_entity_type_id_entity_id (cost=0.00..6,269.32 rows=339,319 width=0) (actual time=14.522..14.522 rows=341,496 loops=1)

  • Index Cond: (entity_type_id = 1)
39. 0.013 0.033 ↑ 1.0 41 1

Hash (cost=1.41..1.41 rows=41 width=20) (actual time=0.032..0.033 rows=41 loops=1)

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

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

Planning time : 1.787 ms
Execution time : 15,107.084 ms