explain.depesz.com

PostgreSQL's explain analyze made readable

Result: B5BK

Settings
# exclusive inclusive rows x rows loops node
1. 2.553 1,745.774 ↓ 100.0 100 1

Limit (cost=310,814.64..310,814.64 rows=1 width=188) (actual time=1,745.742..1,745.774 rows=100 loops=1)

2.          

CTE outfits

3. 36.216 1,295.371 ↓ 1.4 98,877 1

Unique (cost=191,848.55..194,425.27 rows=70,894 width=33) (actual time=1,093.557..1,295.371 rows=98,877 loops=1)

4. 378.452 1,259.155 ↑ 1.0 500,017 1

Sort (cost=191,848.55..193,136.91 rows=515,344 width=33) (actual time=1,093.555..1,259.155 rows=500,017 loops=1)

  • Sort Key: outfit.id_user_app, (COALESCE(outfit_ranking_temp_a.star_count_at_week, 0)) DESC, (COALESCE(outfit_ranking_temp_a.outfit_post_datetime, '1970-07-16 00:00:00'::timestamp without time zone)) DESC
  • Sort Method: external merge Disk: 20496kB
5. 385.472 880.703 ↑ 1.0 500,017 1

Hash Right Join (cost=61,204.37..128,860.33 rows=515,344 width=33) (actual time=307.415..880.703 rows=500,017 loops=1)

  • Hash Cond: (outfit_ranking_temp_a.id_outfit = outfit.id_outfit)
6. 188.841 188.841 ↑ 1.0 900,000 1

Seq Scan on outfit_ranking_temp_a (cost=0.00..47,959.94 rows=900,094 width=16) (actual time=0.006..188.841 rows=900,000 loops=1)

7. 90.262 306.390 ↑ 1.0 500,017 1

Hash (cost=51,742.57..51,742.57 rows=515,344 width=17) (actual time=306.390..306.390 rows=500,017 loops=1)

  • Buckets: 65536 Batches: 16 Memory Usage: 1768kB
8. 216.128 216.128 ↑ 1.0 500,017 1

Seq Scan on outfit (cost=0.00..51,742.57 rows=515,344 width=17) (actual time=0.163..216.128 rows=500,017 loops=1)

  • Filter: ((NOT private_flag) AND (deleted_at IS NULL))
  • Rows Removed by Filter: 499983
9. 89.135 1,743.221 ↓ 2.5 88,100 1

Sort (cost=116,300.76..116,389.37 rows=35,447 width=188) (actual time=1,716.086..1,743.221 rows=88,100 loops=1)

  • Sort Key: user_ranking_temp_a.follower_count_at_week DESC, user_ranking_temp_a.outfit_star_count_at_week DESC, (COALESCE(user_ranking_temp_a.outfit_post_updated_at, '1970-07-16 00:00:00'::timestamp without time zone)) DESC
  • Sort Method: external merge Disk: 17816kB
10. 21.191 1,654.086 ↓ 2.5 88,883 1

Nested Loop (cost=7,159.49..110,349.64 rows=35,447 width=188) (actual time=1,358.295..1,654.086 rows=88,883 loops=1)

11. 29.631 1,435.145 ↓ 2.8 98,875 1

Merge Join (cost=7,159.07..87,751.59 rows=35,447 width=125) (actual time=1,358.276..1,435.145 rows=98,875 loops=1)

  • Merge Cond: (user_app.id_user_app = outfits.id_user_app)
12. 29.949 29.975 ↑ 5.0 99,999 1

Index Scan using user_app_pkey on user_app (cost=29.48..78,661.98 rows=500,431 width=117) (actual time=0.077..29.975 rows=99,999 loops=1)

  • Filter: ((deleted_at IS NULL) AND (NOT (hashed SubPlan 2)))
  • Rows Removed by Filter: 2
13.          

SubPlan (for Index Scan)

14. 0.026 0.026 ↓ 0.0 0 1

Seq Scan on user_block (cost=0.00..29.05 rows=1 width=4) (actual time=0.026..0.026 rows=0 loops=1)

  • Filter: ((deleted_at IS NULL) AND ((id_block_from = 22) OR (id_block_to = 22)))
  • Rows Removed by Filter: 1
15. 55.721 1,375.539 ↓ 1.4 98,877 1

Sort (cost=7,129.59..7,306.82 rows=70,894 width=8) (actual time=1,358.193..1,375.539 rows=98,877 loops=1)

  • Sort Key: outfits.id_user_app
  • Sort Method: external sort Disk: 2128kB
16. 1,319.818 1,319.818 ↓ 1.4 98,877 1

CTE Scan on outfits (cost=0.00..1,417.88 rows=70,894 width=8) (actual time=1,093.559..1,319.818 rows=98,877 loops=1)

17. 197.750 197.750 ↑ 1.0 1 98,875

Index Scan using user_ranking_temp_a_id_user_app_key on user_ranking_temp_a (cost=0.42..0.63 rows=1 width=71) (actual time=0.002..0.002 rows=1 loops=98,875)

  • Index Cond: (id_user_app = user_app.id_user_app)
Planning time : 2.118 ms
Execution time : 1,752.325 ms