explain.depesz.com

PostgreSQL's explain analyze made readable

Result: tXeT

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 14,985.567 ↓ 2.0 20 1

Subquery Scan on relation_list (cost=1,684,628.79..1,684,628.92 rows=10 width=4) (actual time=14,985.529..14,985.567 rows=20 loops=1)

2. 0.029 14,985.559 ↓ 2.0 20 1

Limit (cost=1,684,628.79..1,684,628.82 rows=10 width=1,315) (actual time=14,985.528..14,985.559 rows=20 loops=1)

3. 137.862 14,985.530 ↓ 2.0 20 1

Sort (cost=1,684,628.79..1,684,628.82 rows=10 width=1,315) (actual time=14,985.526..14,985.530 rows=20 loops=1)

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

Subquery Scan on relation_grouped (cost=1,684,618.38..1,684,628.63 rows=10 width=1,315) (actual time=8,787.333..14,847.668 rows=341,157 loops=1)

5. 193.199 14,681.633 ↓ 34,115.7 341,157 1

Group (cost=1,684,618.38..1,684,628.53 rows=10 width=801) (actual time=8,787.330..14,681.633 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. 233.606 5,612.652 ↓ 10.8 341,157 1

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

  • Group Key: edl.entity_id
8.          

CTE user_data_filter

9. 41.350 47.742 ↓ 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.552..47.742 rows=155,719 loops=1)

  • Recheck Cond: (user_id = 1199)
  • Filter: (NOT deleted)
  • Heap Blocks: exact=1509
10. 6.392 6.392 ↓ 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.391..6.392 rows=155,719 loops=1)

  • Index Cond: (user_id = 1199)
11. 84.011 5,379.046 ↓ 11.0 346,244 1

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

12. 306.535 1,539.381 ↓ 12.2 346,244 1

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

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

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

  • Sort Key: edl.ancestor_id, edl.ancestor_type_id
  • Sort Method: external merge Disk: 22056kB
14. 375.458 375.458 ↓ 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.015..375.458 rows=1,023,780 loops=1)

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

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

  • Sort Key: da.entity_id, da.entity_type_id
  • Sort Method: external sort Disk: 3360kB
16. 119.450 119.450 ↓ 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.556..119.450 rows=155,719 loops=1)

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

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

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

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

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

  • Sort Key: edl_1.ancestor_id, edl_1.ancestor_type_id
  • Sort Method: external merge Disk: 84368kB
20. 2,489.156 2,489.156 ↓ 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.032..2,489.156 rows=3,312,396 loops=1)

  • Filter: (parent AND (NOT deleted))
  • Rows Removed by Filter: 14519610
21. 0.006 16.868 ↓ 0.0 0 1

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

  • Sort Key: da_1.entity_id, da_1.entity_type_id
  • Sort Method: quicksort Memory: 25kB
22. 16.862 16.862 ↓ 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=16.862..16.862 rows=0 loops=1)

  • Filter: (NOT self_access)
  • Rows Removed by Filter: 155719
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. 279.766 8,875.782 ↓ 34,115.7 341,157 1

Sort (cost=285,401.92..285,401.95 rows=10 width=76) (actual time=8,787.227..8,875.782 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: 30184kB
25. 137.776 8,596.016 ↓ 34,115.7 341,157 1

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

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

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

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

Merge Left Join (cost=120,593.95..120,741.95 rows=10 width=56) (actual time=5,841.295..7,782.412 rows=341,157 loops=1)

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

Nested Loop Left Join (cost=0.85..140.27 rows=10 width=48) (actual time=5,758.468..7,581.108 rows=341,157 loops=1)

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

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

  • Index Cond: (id = ANY ($3))
  • Filter: ((NOT deleted) AND (client_id = 1007))
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 = 1007) AND (chart_id = 2))
31. 0.047 82.821 ↑ 3.4 84 1

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

  • Group Key: au.entity_id
32. 0.054 82.774 ↑ 3.1 91 1

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

  • Sort Key: au.entity_id
  • Sort Method: quicksort Memory: 29kB
33. 66.100 82.720 ↑ 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=17.624..82.720 rows=91 loops=1)

  • Recheck Cond: (entity_type_id = 1)
  • Filter: ((work_flow_status_id = 5) OR (action_id = 9))
  • Rows Removed by Filter: 341405
  • Heap Blocks: exact=7791
34. 16.620 16.620 ↓ 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=16.619..16.620 rows=341,496 loops=1)

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

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

  • Group Key: au_1.entity_id
36. 201.299 315.043 ↓ 1.0 341,496 1

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

  • Sort Key: au_1.entity_id
  • Sort Method: external merge Disk: 8704kB
37. 99.121 113.744 ↓ 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.623..113.744 rows=341,496 loops=1)

  • Recheck Cond: (entity_type_id = 1)
  • Heap Blocks: exact=7791
38. 14.623 14.623 ↓ 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.622..14.623 rows=341,496 loops=1)

  • Index Cond: (entity_type_id = 1)
39. 0.010 0.027 ↑ 1.0 41 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
40. 0.017 0.017 ↑ 1.0 41 1

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

Planning time : 1.689 ms
Execution time : 15,013.165 ms