explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 7wRR

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.009 46,120.419 ↑ 1.0 4 1

Limit (cost=14,736.19..14,736.20 rows=4 width=1,127) (actual time=46,120.410..46,120.419 rows=4 loops=1)

2. 32.961 46,120.410 ↑ 5,661.8 4 1

Sort (cost=14,736.19..14,792.81 rows=22,647 width=1,127) (actual time=46,120.409..46,120.410 rows=4 loops=1)

  • Sort Key: news.news_top DESC, news.news_datetime DESC NULLS LAST
  • Sort Method: top-N heapsort Memory: 33kB
3. 27.472 46,087.449 ↓ 1.0 22,951 1

Hash Left Join (cost=239.94..14,396.49 rows=22,647 width=1,127) (actual time=28.913..46,087.449 rows=22,951 loops=1)

  • Hash Cond: (news.news_id = news_comments_count.news_id)
4. 46,057.558 46,059.672 ↓ 1.0 22,951 1

Bitmap Heap Scan on news_view news (cost=230.85..14,327.95 rows=22,647 width=1,123) (actual time=28.590..46,059.672 rows=22,951 loops=1)

  • Recheck Cond: ((news_city_ids @> '{23}'::integer[]) OR (news_city_ids = '{}'::integer[]))
  • Filter: (news_datetime <= now())
  • Heap Blocks: exact=7182
5. 0.001 2.114 ↓ 0.0 0 1

BitmapOr (cost=230.85..230.85 rows=22,870 width=0) (actual time=2.114..2.114 rows=0 loops=1)

6. 2.038 2.038 ↓ 1.0 22,184 1

Bitmap Index Scan on news_view_k_city (cost=0.00..206.23 rows=22,164 width=0) (actual time=2.037..2.038 rows=22,184 loops=1)

  • Index Cond: (news_city_ids @> '{23}'::integer[])
7. 0.075 0.075 ↓ 1.1 767 1

Bitmap Index Scan on news_view_k_city (cost=0.00..13.30 rows=706 width=0) (actual time=0.075..0.075 rows=767 loops=1)

  • Index Cond: (news_city_ids = '{}'::integer[])
8. 0.153 0.305 ↑ 1.0 315 1

Hash (cost=5.15..5.15 rows=315 width=8) (actual time=0.305..0.305 rows=315 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
9. 0.152 0.152 ↑ 1.0 315 1

Seq Scan on comments_news_count news_comments_count (cost=0.00..5.15 rows=315 width=8) (actual time=0.016..0.152 rows=315 loops=1)