explain.depesz.com

PostgreSQL's explain analyze made readable

Result: uQv5

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 20.900 ↑ 503.5 2 1

Sort (cost=780.77..783.29 rows=1,007 width=96) (actual time=20.900..20.900 rows=2 loops=1)

  • Sort Key: (CASE WHEN ((t.tx_date >= '2018-01-01'::date) AND (t.tx_date <= '2018-12-31'::date)) THEN 'previousPeriod'::text WHEN ((t.tx_date >= '2019-01-01'::date) AND (t.tx_date <= '2019-12-31'::date)) THEN 'currentPeriod'::text ELSE NULL::text END), (sum((t.home_amount / '10000000'::numeric)))
  • Sort Method: quicksort Memory: 25kB
2. 1.364 20.892 ↑ 503.5 2 1

HashAggregate (cost=702.85..730.54 rows=1,007 width=96) (actual time=20.889..20.892 rows=2 loops=1)

  • Group Key: (t.item_id)::character varying, CASE WHEN ((t.tx_date >= '2018-01-01'::date) AND (t.tx_date <= '2018-12-31'::date)) THEN 'previousPeriod'::text WHEN ((t.tx_date >= '2019-01-01'::date) AND (t.tx_date <= '2019-12-31'::date)) THEN 'currentPeriod'::text ELSE NULL::text END
3. 1.329 19.528 ↓ 3.4 3,444 1

Nested Loop (cost=1.26..692.78 rows=1,007 width=70) (actual time=8.895..19.528 rows=3,444 loops=1)

4. 2.530 2.530 ↓ 39.6 1,741 1

Index Scan using accounts_pk on accounts a (cost=0.56..345.48 rows=44 width=13) (actual time=0.067..2.530 rows=1,741 loops=1)

  • Index Cond: (company_id = 182519665.000000000)
  • Filter: (account_type_id = '10'::numeric)
  • Rows Removed by Filter: 130
5. 0.000 15.669 ↑ 2.5 2 1,741

Append (cost=0.70..7.50 rows=5 width=28) (actual time=0.007..0.009 rows=2 loops=1,741)

6. 15.669 15.669 ↑ 2.5 2 1,741

Index Scan using txdetails_p9_account_id_company_id_tx_date_idx on txdetails_p9 t (cost=0.70..7.47 rows=5 width=28) (actual time=0.007..0.009 rows=2 loops=1,741)

  • Index Cond: ((account_id = a.account_id) AND (company_id = 182519665.000000000) AND (tx_date >= '2018-01-01'::date) AND (tx_date <= '2019-12-31'::date))
  • Filter: ((is_no_post IS NULL) AND (CASE WHEN ((tx_date >= '2018-01-01'::date) AND (tx_date <= '2018-12-31'::date)) THEN 'previousPeriod'::text WHEN ((tx_date >= '2019-01-01'::date) AND (tx_date <= '2019-12-31'::date)) THEN 'currentPeriod'::text ELSE NULL::text END IS NOT NULL))
Planning time : 1.255 ms
Execution time : 20.965 ms