explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1wF4

Settings
# exclusive inclusive rows x rows loops node
1. 0.080 3.441 ↑ 2.8 60 1

Hash Left Join (cost=636.57..638.65 rows=165 width=76) (actual time=3.239..3.441 rows=60 loops=1)

  • Hash Cond: (daily_sums.profile_id = base_row.profile_id)
2.          

CTE base_row

3. 0.031 0.702 ↑ 159.0 1 1

Unique (cost=315.90..315.99 rows=159 width=135) (actual time=0.626..0.702 rows=1 loops=1)

4. 0.279 0.671 ↓ 2.4 406 1

Sort (cost=315.90..315.99 rows=166 width=135) (actual time=0.625..0.671 rows=406 loops=1)

  • Sort Key: flywheel_dash_metrics_ongoing_totals.date DESC
  • Sort Method: quicksort Memory: 81kB
5. 0.286 0.392 ↓ 2.4 406 1

Bitmap Heap Scan on flywheel_dash_metrics_ongoing_totals (cost=4.42..314.68 rows=166 width=135) (actual time=0.122..0.392 rows=406 loops=1)

  • Recheck Cond: ((profile_id = '3811963422597420'::bigint) AND (date < '2019-08-01'::date))
  • Heap Blocks: exact=59
6. 0.106 0.106 ↓ 2.4 406 1

Bitmap Index Scan on flywheel_dash_metrics_ongoing_totals_pkey (cost=0.00..4.42 rows=166 width=0) (actual time=0.106..0.106 rows=406 loops=1)

  • Index Cond: ((profile_id = '3811963422597420'::bigint) AND (date < '2019-08-01'::date))
7. 0.158 2.636 ↑ 2.8 60 1

WindowAgg (cost=319.07..319.90 rows=165 width=76) (actual time=2.492..2.636 rows=60 loops=1)

8.          

CTE daily_sums

9. 0.569 2.388 ↑ 2.8 60 1

GroupAggregate (cost=315.79..316.87 rows=165 width=76) (actual time=1.754..2.388 rows=60 loops=1)

  • Group Key: sponsored_brands_daily_campaign_performances.profile_id, sponsored_brands_daily_campaign_performances.date
10. 0.471 1.819 ↓ 4.8 798 1

Sort (cost=315.79..315.88 rows=165 width=21) (actual time=1.726..1.819 rows=798 loops=1)

  • Sort Key: sponsored_brands_daily_campaign_performances.date
  • Sort Method: quicksort Memory: 87kB
11. 1.035 1.348 ↓ 4.8 798 1

Bitmap Heap Scan on sponsored_brands_daily_campaign_performances (cost=6.82..314.58 rows=165 width=21) (actual time=0.365..1.348 rows=798 loops=1)

  • Recheck Cond: ((profile_id = '3811963422597420'::bigint) AND (date >= '2019-08-01'::date) AND (date <= '2019-09-29'::date))
  • Heap Blocks: exact=218
12. 0.313 0.313 ↓ 6.0 993 1

Bitmap Index Scan on sb_daily_campaign_performances_profile_id_campaign_id_date_pkey (cost=0.00..6.82 rows=165 width=0) (actual time=0.313..0.313 rows=993 loops=1)

  • Index Cond: ((profile_id = '3811963422597420'::bigint) AND (date >= '2019-08-01'::date) AND (date <= '2019-09-29'::date))
13. 0.032 2.478 ↑ 2.8 60 1

Sort (cost=2.21..2.29 rows=165 width=76) (actual time=2.471..2.478 rows=60 loops=1)

  • Sort Key: daily_sums.date
  • Sort Method: quicksort Memory: 29kB
14. 2.446 2.446 ↑ 2.8 60 1

CTE Scan on daily_sums (cost=0.00..0.99 rows=165 width=76) (actual time=1.758..2.446 rows=60 loops=1)

15. 0.020 0.725 ↑ 159.0 1 1

Hash (cost=0.95..0.95 rows=159 width=48) (actual time=0.725..0.725 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
16. 0.705 0.705 ↑ 159.0 1 1

CTE Scan on base_row (cost=0.00..0.95 rows=159 width=48) (actual time=0.629..0.705 rows=1 loops=1)

Planning time : 0.536 ms
Execution time : 3.607 ms