Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Limit (cost=316926.14..316926.39 rows=100 width=20) (actual time=2326.812..2326.830 rows=100 loops=1)
- -> Sort (cost=316926.14..317014.83 rows=35476 width=20) (actual time=2326.809..2326.820 rows=100 loops=1)
- Sort Key: (count(p.id)) DESC
- Sort Method: top-N heapsort Memory: 32kB
- -> HashAggregate (cost=315215.51..315570.27 rows=35476 width=20) (actual time=2311.296..2321.739 rows=34608 loops=1)
- Group Key: u.id
- -> Hash Join (cost=1176.89..308201.88 rows=1402727 width=16) (actual time=16.538..1784.546 rows=1910831 loops=1)
- Hash Cond: (p.user_id = u.id)
- -> Seq Scan on posts p (cost=0.00..286185.34 rows=1816634 width=8) (actual time=0.103..1144.681 rows=2173916 loops=1)
- -> Hash (cost=733.44..733.44 rows=35476 width=12) (actual time=15.763..15.763 rows=34609 loops=1)
- Buckets: 65536 Batches: 1 Memory Usage: 2021kB
- -> Seq Scan on users u (cost=0.00..733.44 rows=35476 width=12) (actual time=0.033..6.521 rows=34609 loops=1)
- Filter: (username IS NOT NULL)
- Rows Removed by Filter: 11335
- With set enable_seqscan = false even worse:
- Limit (cost=1160881.74..1160881.99 rows=100 width=20) (actual time=2758.086..2758.107 rows=100 loops=1)
- -> Sort (cost=1160881.74..1160970.43 rows=35476 width=20) (actual time=2758.084..2758.098 rows=100 loops=1)
- Sort Key: (count(p.id)) DESC
- Sort Method: top-N heapsort Memory: 32kB
- -> GroupAggregate (cost=0.79..1159525.87 rows=35476 width=20) (actual time=0.095..2749.859 rows=34608 loops=1)
- Group Key: u.id
- -> Merge Join (cost=0.79..1152157.48 rows=1402727 width=16) (actual time=0.036..2537.064 rows=1910831 loops=1)
- Merge Cond: (u.id = p.user_id)
- -> Index Scan using users_pkey on users u (cost=0.29..2404.83 rows=35476 width=12) (actual time=0.016..41.163 rows=34609 loops=1)
- Filter: (username IS NOT NULL)
- Rows Removed by Filter: 11335
- -> Index Scan using posts_user_id_index on posts p (cost=0.43..1131472.19 rows=1816634 width=8) (actual time=0.012..2191.856 rows=2173916 loops=1)
- Planning time: 1.281 ms
- Execution time: 2758.187 ms
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement