explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wP5W

Settings
# exclusive inclusive rows x rows loops node
1. 0.006 11,713.098 ↓ 2.0 20 1

Subquery Scan on relation_list (cost=1,415,662.54..1,415,662.67 rows=10 width=4) (actual time=11,713.074..11,713.098 rows=20 loops=1)

2. 0.017 11,713.092 ↓ 2.0 20 1

Limit (cost=1,415,662.54..1,415,662.57 rows=10 width=1,299) (actual time=11,713.073..11,713.092 rows=20 loops=1)

3. 140.345 11,713.075 ↓ 2.0 20 1

Sort (cost=1,415,662.54..1,415,662.57 rows=10 width=1,299) (actual time=11,713.072..11,713.075 rows=20 loops=1)

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

Subquery Scan on relation_grouped (cost=1,415,657.18..1,415,662.38 rows=10 width=1,299) (actual time=7,984.434..11,572.730 rows=341,157 loops=1)

5. 0.000 11,420.264 ↓ 34,115.7 341,157 1

Group (cost=1,415,657.18..1,415,662.28 rows=10 width=769) (actual time=7,984.432..11,420.264 rows=341,157 loops=1)

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

Initplan (for Group)

7. 253.559 5,759.871 ↓ 10.4 341,157 1

HashAggregate (cost=1,415,186.22..1,415,515.37 rows=32,915 width=4) (actual time=5,654.747..5,759.871 rows=341,157 loops=1)

  • Group Key: edl.entity_id
8.          

CTE user_data_filter

9. 42.198 48.481 ↓ 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.444..48.481 rows=155,719 loops=1)

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

  • Index Cond: (user_id = 1199)
11. 81.325 5,506.312 ↓ 10.5 346,244 1

Append (cost=343,694.13..1,372,688.92 rows=32,915 width=4) (actual time=1,005.165..5,506.312 rows=346,244 loops=1)

12. 299.499 1,590.295 ↓ 11.7 346,244 1

Merge Join (cost=343,694.13..352,148.10 rows=29,709 width=4) (actual time=1,005.164..1,590.295 rows=346,244 loops=1)

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

Sort (cost=334,687.31..337,220.06 rows=1,013,099 width=12) (actual time=771.768..989.010 rows=1,023,780 loops=1)

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

Index Scan using idx_entity_data_link_entity_type_id on entity_data_link edl (cost=0.56..216,314.44 rows=1,013,099 width=12) (actual time=0.020..391.255 rows=1,023,780 loops=1)

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

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

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

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

Nested Loop (cost=871,018.75..1,020,047.10 rows=3,206 width=4) (actual time=3,834.692..3,834.692 rows=0 loops=1)

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

Merge Join (cost=871,018.19..897,472.54 rows=96,810 width=40) (actual time=3,834.691..3,834.691 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,330.834 3,814.079 ↑ 3,301,357.0 1 1

Sort (cost=862,011.36..870,264.76 rows=3,301,357 width=16) (actual time=3,814.079..3,814.079 rows=1 loops=1)

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

Seq Scan on entity_data_link edl_1 (cost=0.00..448,143.08 rows=3,301,357 width=16) (actual time=0.013..2,483.245 rows=3,312,396 loops=1)

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

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

  • Sort Key: da_1.entity_id, da_1.entity_type_id
  • Sort Method: quicksort Memory: 25kB
22. 20.599 20.599 ↓ 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=20.599..20.599 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.20 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. 263.990 8,068.428 ↓ 34,115.7 341,157 1

Sort (cost=141.81..141.84 rows=10 width=60) (actual time=7,984.380..8,068.428 rows=341,157 loops=1)

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

Nested Loop Left Join (cost=2.78..141.64 rows=10 width=60) (actual time=5,900.661..7,804.438 rows=341,157 loops=1)

26. 168.651 6,751.265 ↓ 34,115.7 341,157 1

Hash Left Join (cost=2.35..56.99 rows=10 width=60) (actual time=5,900.642..6,751.265 rows=341,157 loops=1)

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

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

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

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

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

Seq Scan on time_zone tz (cost=0.00..1.41 rows=41 width=20) (actual time=0.009..0.019 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.531 ms
Execution time : 11,726.878 ms