explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 4b6

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 11,255.760 ↓ 2.0 20 1

Subquery Scan on relation_list (cost=1,399,363.93..1,399,364.05 rows=10 width=4) (actual time=11,255.735..11,255.760 rows=20 loops=1)

2. 0.018 11,255.753 ↓ 2.0 20 1

Limit (cost=1,399,363.93..1,399,363.95 rows=10 width=1,299) (actual time=11,255.733..11,255.753 rows=20 loops=1)

3. 135.133 11,255.735 ↓ 2.0 20 1

Sort (cost=1,399,363.93..1,399,363.95 rows=10 width=1,299) (actual time=11,255.732..11,255.735 rows=20 loops=1)

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

Subquery Scan on relation_grouped (cost=1,399,358.56..1,399,363.76 rows=10 width=1,299) (actual time=7,789.962..11,120.602 rows=341,157 loops=1)

5. 0.000 10,976.686 ↓ 34,115.7 341,157 1

Group (cost=1,399,358.56..1,399,363.66 rows=10 width=769) (actual time=7,789.959..10,976.686 rows=341,157 loops=1)

  • Group Key: r.id, tz.time_zone, crp.color
6.          

Initplan (for Group)

7. 225.771 5,595.391 ↓ 10.8 341,157 1

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

  • Group Key: edl.entity_id
8.          

CTE user_data_filter

9. 41.546 48.053 ↓ 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.669..48.053 rows=155,719 loops=1)

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

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

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

12. 292.335 1,531.925 ↓ 12.2 346,244 1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • Sort Key: da_1.entity_id, da_1.entity_type_id
  • Sort Method: quicksort Memory: 25kB
22. 16.143 16.143 ↓ 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.142..16.143 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. 249.873 7,868.506 ↓ 34,115.7 341,157 1

Sort (cost=142.11..142.13 rows=10 width=60) (actual time=7,789.899..7,868.506 rows=341,157 loops=1)

  • Sort Key: r.id, tz.time_zone, crp.color
  • Sort Method: external merge Disk: 24776kB
25. 364.541 7,618.633 ↓ 34,115.7 341,157 1

Nested Loop Left Join (cost=2.78..141.94 rows=10 width=60) (actual time=5,735.050..7,618.633 rows=341,157 loops=1)

26. 167.578 6,571.778 ↓ 34,115.7 341,157 1

Hash Left Join (cost=2.35..57.29 rows=10 width=60) (actual time=5,735.032..6,571.778 rows=341,157 loops=1)

  • Hash Cond: (r.time_zone_id = tz.id)
27. 6,404.171 6,404.171 ↓ 34,115.7 341,157 1

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

  • Index Cond: (id = ANY ($3))
  • Filter: ((NOT deleted) AND (client_id = 1007))
28. 0.013 0.029 ↑ 1.0 41 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
29. 0.016 0.016 ↑ 1.0 41 1

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

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))
Planning time : 1.250 ms
Execution time : 11,281.347 ms