explain.depesz.com

PostgreSQL's explain analyze made readable

Result: eO4N

Settings
# exclusive inclusive rows x rows loops node
1. 0.021 23.135 ↓ 6.5 13 1

Merge Left Join (cost=13,453.54..13,542.99 rows=2 width=100) (actual time=1.410..23.135 rows=13 loops=1)

  • Merge Cond: (all_funds.id = holdings_1.fund_id)
2. 0.017 22.666 ↓ 6.5 13 1

Merge Left Join (cost=6,729.10..6,815.52 rows=2 width=36) (actual time=0.995..22.666 rows=13 loops=1)

  • Merge Cond: (all_funds.id = bought.fund_id)
3. 21.686 21.686 ↓ 6.5 13 1

Index Only Scan using funds_pkey on funds all_funds (cost=0.25..86.55 rows=2 width=4) (actual time=0.033..21.686 rows=13 loops=1)

  • Heap Fetches: 2540
4. 0.009 0.963 ↑ 1.9 7 1

Sort (cost=6,728.84..6,728.88 rows=13 width=36) (actual time=0.960..0.963 rows=7 loops=1)

  • Sort Key: bought.fund_id
  • Sort Method: quicksort Memory: 25kB
5. 0.001 0.954 ↑ 1.9 7 1

Subquery Scan on bought (cost=6,727.79..6,728.60 rows=13 width=36) (actual time=0.951..0.954 rows=7 loops=1)

6. 0.151 0.953 ↑ 1.9 7 1

HashAggregate (cost=6,727.79..6,728.21 rows=13 width=36) (actual time=0.950..0.953 rows=7 loops=1)

  • Group Key: holdings.fund_id
7. 0.802 0.802 ↑ 3.3 885 1

Index Scan using index_holdings_on_investment_account_id on holdings (cost=0.70..6,713.02 rows=2,955 width=12) (actual time=0.032..0.802 rows=885 loops=1)

  • Index Cond: (investment_account_id = '5433ca8c-dc57-4596-b83b-240a569879ba'::uuid)
  • Filter: (((type)::text = ANY ('{HoldingBought,HoldingSplit}'::text[])) AND (created_at <= '2019-11-05 23:59:59.999999'::timestamp without time zone) AND ((status)::text = ANY ('{pending,settled}'::text[])) AND (present_to_user = ANY ('{t,f}'::boolean[])))
  • Rows Removed by Filter: 101
8. 0.030 0.448 ↑ 1.9 7 1

GroupAggregate (cost=6,724.45..6,726.98 rows=13 width=36) (actual time=0.412..0.448 rows=7 loops=1)

  • Group Key: holdings_1.fund_id
9. 0.028 0.418 ↑ 2.8 101 1

Sort (cost=6,724.45..6,725.15 rows=281 width=12) (actual time=0.406..0.418 rows=101 loops=1)

  • Sort Key: holdings_1.fund_id
  • Sort Method: quicksort Memory: 29kB
10. 0.390 0.390 ↑ 2.8 101 1

Index Scan using index_holdings_on_investment_account_id on holdings holdings_1 (cost=0.70..6,713.02 rows=281 width=12) (actual time=0.014..0.390 rows=101 loops=1)

  • Index Cond: (investment_account_id = '5433ca8c-dc57-4596-b83b-240a569879ba'::uuid)
  • Filter: ((created_at <= '2019-11-05 23:59:59.999999'::timestamp without time zone) AND ((status)::text = ANY ('{pending,settled}'::text[])) AND (present_to_user = ANY ('{t,f}'::boolean[])) AND ((type)::text = 'HoldingSold'::text))
  • Rows Removed by Filter: 885
Planning time : 9.509 ms
Execution time : 23.190 ms