explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Nbxi

Settings
# exclusive inclusive rows x rows loops node
1. 0.006 15,088.705 ↓ 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,088.675..15,088.705 rows=20 loops=1)

2. 0.023 15,088.699 ↓ 2.0 20 1

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

3. 141.938 15,088.676 ↓ 2.0 20 1

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

  • Sort Key: relation_grouped.id DESC
  • Sort Method: top-N heapsort Memory: 26kB
4. 160.523 14,946.738 ↓ 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,791.627..14,946.738 rows=341,157 loops=1)

5. 332.088 14,786.215 ↓ 34,115.7 341,157 1

Group (cost=1,684,618.39..1,684,628.54 rows=10 width=801) (actual time=8,791.625..14,786.215 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.219 5,571.672 ↓ 10.8 341,157 1

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

  • Group Key: edl.entity_id
8.          

CTE user_data_filter

9. 40.688 47.100 ↓ 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.569..47.100 rows=155,719 loops=1)

  • Recheck Cond: (user_id = 1,199)
  • Filter: (NOT deleted)
  • Heap Blocks: exact=1,509
10. 6.412 6.412 ↓ 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.411..6.412 rows=155,719 loops=1)

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

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

12. 298.250 1,534.758 ↓ 12.2 346,244 1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • Sort Key: da_1.entity_id, da_1.entity_type_id
  • Sort Method: quicksort Memory: 25kB
22. 16.835 16.835 ↓ 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.834..16.835 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. 290.795 8,882.455 ↓ 34,115.7 341,157 1

Sort (cost=285,401.93..285,401.96 rows=10 width=76) (actual time=8,791.560..8,882.455 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. 139.620 8,591.660 ↓ 34,115.7 341,157 1

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

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

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

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

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

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

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

29. 6,421.295 6,421.295 ↓ 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,714.941..6,421.295 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.050 86.009 ↑ 3.4 84 1

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

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

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

  • Sort Key: au.entity_id
  • Sort Method: quicksort Memory: 29kB
33. 71.571 85.904 ↑ 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.334..85.904 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.333 14.333 ↓ 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.333..14.333 rows=341,496 loops=1)

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

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

  • Group Key: au_1.entity_id
36. 208.815 323.152 ↓ 1.0 341,496 1

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

  • Sort Key: au_1.entity_id
  • Sort Method: external merge Disk: 8,704kB
37. 98.562 114.337 ↓ 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=16.759..114.337 rows=341,496 loops=1)

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

  • Index Cond: (entity_type_id = 1)
39. 0.011 0.030 ↑ 1.0 41 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
40. 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.008..0.019 rows=41 loops=1)

Planning time : 1.839 ms
Execution time : 15,116.214 ms