explain.depesz.com

PostgreSQL's explain analyze made readable

Result: EBey

Settings
# exclusive inclusive rows x rows loops node
1. 33.578 1,631.907 ↑ 13.0 20,181 1

Sort (cost=130,177.17..130,832.38 rows=262,083 width=96) (actual time=1,630.821..1,631.907 rows=20,181 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 / '1
  • Sort Method: quicksort Memory: 2345kB
2. 140.898 1,598.329 ↑ 13.0 20,181 1

GroupAggregate (cost=88,047.30..98,718.14 rows=262,083 width=96) (actual time=1,345.587..1,598.329 rows=20,181 loops=1)

  • Group Key: ((t.customer_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 E
3. 836.428 1,457.431 ↓ 1.4 399,348 1

Sort (cost=88,047.30..88,740.01 rows=277,085 width=70) (actual time=1,345.573..1,457.431 rows=399,348 loops=1)

  • Sort Key: ((t.customer_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'::t
  • Sort Method: external merge Disk: 14264kB
4. 79.068 621.003 ↓ 1.4 399,348 1

Nested Loop (cost=1.26..56,340.45 rows=277,085 width=70) (actual time=0.248..621.003 rows=399,348 loops=1)

5. 0.360 0.360 ↓ 1.5 45 1

Index Scan using accounts_pk on accounts a (cost=0.56..235.72 rows=30 width=13) (actual time=0.064..0.360 rows=45 loops=1)

  • Index Cond: (company_id = 79451168.000000000)
  • Filter: (account_type_id = '10'::numeric)
  • Rows Removed by Filter: 213
6. 26.820 541.575 ↓ 6.0 8,874 45

Append (cost=0.70..1,716.71 rows=1,491 width=28) (actual time=0.012..12.035 rows=8,874 loops=45)

7. 514.755 514.755 ↓ 6.0 8,874 45

Index Scan using txdetails_p0_account_id_company_id_tx_date_idx on txdetails_p0 t (cost=0.70..1,709.25 rows=1,491 width=28) (actual time=0.012..11.439 rows=8,874 loops=45)

  • Index Cond: ((account_id = a.account_id) AND (company_id = 79451168.000000000) AND (tx_date >= '2018-01-01'::date) AND (tx_date <= '2019-12-31'::date))
  • Filter: (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
Planning time : 2.798 ms
Execution time : 1,634.987 ms