explain.depesz.com

PostgreSQL's explain analyze made readable

Result: nG29

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 7,626.870 ↓ 0.0 0 1

Sort (cost=5,514,097.47..5,514,097.70 rows=93 width=68) (actual time=7,626.870..7,626.870 rows=0 loops=1)

  • Sort Key: date_series.date
  • Sort Method: quicksort Memory: 25kB
2. 0.002 7,626.868 ↓ 0.0 0 1

Merge Right Join (cost=5,507,747.96..5,514,094.43 rows=93 width=68) (actual time=7,626.868..7,626.868 rows=0 loops=1)

  • Merge Cond: ((t.item_id = entity.item_id) AND ((date_part('day'::text, (date(c.cash_date))::timestamp without time zone)) = ((date_series.date_of_month)::double precision)) AND ((date_part('month'::text, (date(c.cash_date))::timestamp without time zone)) = ((date_series.month)::double precision)) AND ((date_part('year'::text, (date(c.cash_date))::timestamp without time zone)) = ((date_series.year)::double precision)))
3. 0.000 1,988.465 ↓ 0.0 0 1

Finalize GroupAggregate (cost=3,621,629.45..3,627,069.93 rows=32,860 width=61) (actual time=1,988.464..1,988.465 rows=0 loops=1)

  • Group Key: t.item_id, (date_part('day'::text, (date(c.cash_date))::timestamp without time zone)), (date_part('month'::text, (date(c.cash_date))::timestamp without time zone)), (date_part('year'::text, (date(c.cash_date))::timestamp without time zone))
4. 4.635 1,988.561 ↓ 0.0 0 1

Gather Merge (cost=3,621,629.45..3,625,509.07 rows=27,384 width=61) (actual time=1,988.464..1,988.561 rows=0 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
5. 0.001 1,983.926 ↓ 0.0 0 3 / 3

Partial GroupAggregate (cost=3,620,629.42..3,621,348.25 rows=13,692 width=61) (actual time=1,983.926..1,983.926 rows=0 loops=3)

  • Group Key: t.item_id, (date_part('day'::text, (date(c.cash_date))::timestamp without time zone)), (date_part('month'::text, (date(c.cash_date))::timestamp without time zone)), (date_part('year'::text, (date(c.cash_date))::timestamp without time zone))
6. 0.023 1,983.925 ↓ 0.0 0 3 / 3

Sort (cost=3,620,629.42..3,620,663.65 rows=13,692 width=35) (actual time=1,983.925..1,983.925 rows=0 loops=3)

  • Sort Key: t.item_id, (date_part('day'::text, (date(c.cash_date))::timestamp without time zone)), (date_part('month'::text, (date(c.cash_date))::timestamp without time zone)), (date_part('year'::text, (date(c.cash_date))::timestamp without time zone))
  • Sort Method: quicksort Memory: 25kB
  • Worker 0: Sort Method: quicksort Memory: 25kB
  • Worker 1: Sort Method: quicksort Memory: 25kB
7. 0.001 1,983.902 ↓ 0.0 0 3 / 3

Nested Loop (cost=347.43..3,619,688.71 rows=13,692 width=35) (actual time=1,983.901..1,983.902 rows=0 loops=3)

8. 0.001 1,983.901 ↓ 0.0 0 3 / 3

Hash Join (cost=346.73..3,616,938.04 rows=832 width=32) (actual time=1,983.901..1,983.901 rows=0 loops=3)

  • Hash Cond: (c.account_id = a.account_id)
9. 0.002 1,983.900 ↓ 0.0 0 3 / 3

Parallel Append (cost=0.70..3,616,573.91 rows=6,805 width=37) (actual time=1,983.900..1,983.900 rows=0 loops=3)

10. 1,983.898 1,983.898 ↓ 0.0 0 3 / 3

Parallel Index Scan using cashbasis_p1_pkey on cashbasis_p1 c (cost=0.70..3,616,539.89 rows=6,805 width=37) (actual time=1,983.898..1,983.898 rows=0 loops=3)

  • Index Cond: (company_id = 109287618.000000000)
  • Filter: ((date(cash_date) >= '2019-01-01'::date) AND (date(cash_date) <= '2019-01-31'::date))
  • Rows Removed by Filter: 1529103
11. 0.000 0.000 ↓ 0.0 0 / 3

Hash (cost=345.48..345.48 rows=44 width=13) (never executed)

12. 0.000 0.000 ↓ 0.0 0 / 3

Index Scan using accounts_pk on accounts a (cost=0.56..345.48 rows=44 width=13) (never executed)

  • Index Cond: (company_id = 109287618.000000000)
  • Filter: (account_type_id = '10'::numeric)
13. 0.000 0.000 ↓ 0.0 0 / 3

Append (cost=0.70..2.93 rows=1 width=23) (never executed)

14. 0.000 0.000 ↓ 0.0 0 / 3

Index Scan using txdetails_p1_pkey on txdetails_p1 t (cost=0.70..2.92 rows=1 width=23) (never executed)

  • Index Cond: ((company_id = 109287618.000000000) AND (tx_id = c.tx_id) AND (sequence = c.sequence))
  • Filter: (is_no_post IS NULL)
15. 0.009 5,638.401 ↓ 0.0 0 1

Sort (cost=1,886,118.52..1,886,118.75 rows=93 width=21) (actual time=5,638.401..5,638.401 rows=0 loops=1)

  • Sort Key: entity.item_id, ((date_series.date_of_month)::double precision), ((date_series.month)::double precision), ((date_series.year)::double precision)
  • Sort Method: quicksort Memory: 25kB
16. 0.020 5,638.392 ↓ 0.0 0 1

Nested Loop (cost=1,886,021.46..1,886,115.47 rows=93 width=21) (actual time=5,638.391..5,638.392 rows=0 loops=1)

17. 0.526 0.526 ↑ 1.0 31 1

Seq Scan on date_series (cost=0.00..92.81 rows=31 width=16) (actual time=0.125..0.526 rows=31 loops=1)

  • Filter: ((date >= '2019-01-01'::date) AND (date <= '2019-01-31'::date))
  • Rows Removed by Filter: 3623
18. 0.000 5,637.846 ↓ 0.0 0 31

Materialize (cost=1,886,021.46..1,886,021.51 rows=3 width=5) (actual time=181.866..181.866 rows=0 loops=31)

19. 0.001 5,637.853 ↓ 0.0 0 1

Subquery Scan on entity (cost=1,886,021.46..1,886,021.49 rows=3 width=5) (actual time=5,637.853..5,637.853 rows=0 loops=1)

20. 0.001 5,637.852 ↓ 0.0 0 1

Limit (cost=1,886,021.46..1,886,021.46 rows=3 width=37) (actual time=5,637.852..5,637.852 rows=0 loops=1)

21. 0.002 5,637.851 ↓ 0.0 0 1

Sort (cost=1,886,021.46..1,886,025.03 rows=1,429 width=37) (actual time=5,637.851..5,637.851 rows=0 loops=1)

  • Sort Key: (sum((c_1.home_amount / '10000000'::numeric)))
  • Sort Method: quicksort Memory: 25kB
22. 0.000 5,637.849 ↓ 0.0 0 1

Finalize GroupAggregate (cost=1,885,587.04..1,886,002.99 rows=1,429 width=37) (actual time=5,637.848..5,637.849 rows=0 loops=1)

  • Group Key: t_1.item_id
23. 6.279 5,639.459 ↓ 0.0 0 1

Gather Merge (cost=1,885,587.04..1,885,963.69 rows=2,858 width=37) (actual time=5,637.847..5,639.459 rows=0 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
24. 0.001 5,633.180 ↓ 0.0 0 3 / 3

Partial GroupAggregate (cost=1,884,587.02..1,884,633.78 rows=1,429 width=37) (actual time=5,633.180..5,633.180 rows=0 loops=3)

  • Group Key: t_1.item_id
25. 0.017 5,633.179 ↓ 0.0 0 3 / 3

Sort (cost=1,884,587.02..1,884,594.24 rows=2,890 width=11) (actual time=5,633.179..5,633.179 rows=0 loops=3)

  • Sort Key: t_1.item_id
  • Sort Method: quicksort Memory: 25kB
  • Worker 0: Sort Method: quicksort Memory: 25kB
  • Worker 1: Sort Method: quicksort Memory: 25kB
26. 0.001 5,633.162 ↓ 0.0 0 3 / 3

Hash Join (cost=347.43..1,884,420.89 rows=2,890 width=11) (actual time=5,633.162..5,633.162 rows=0 loops=3)

  • Hash Cond: (c_1.account_id = a_1.account_id)
27. 262.013 5,633.161 ↓ 0.0 0 3 / 3

Nested Loop (cost=1.40..1,884,012.05 rows=23,619 width=24) (actual time=5,633.161..5,633.161 rows=0 loops=3)

28. 45.234 597.036 ↓ 1.4 596,764 3 / 3

Parallel Append (cost=0.70..669,356.23 rows=416,645 width=23) (actual time=0.035..597.036 rows=596,764 loops=3)

29. 551.802 551.802 ↓ 1.4 596,764 3 / 3

Parallel Index Only Scan using txdetails_p1_company_id_date_tx_date_is_no_post_tx_id_seque_idx on txdetails_p1 t_1 (cost=0.70..667,273.00 rows=416,645 width=23) (actual time=0.034..551.802 rows=596,764 loops=3)

  • Index Cond: ((company_id = 109287618.000000000) AND (is_no_post IS NULL) AND (item_id IS NOT NULL))
  • Heap Fetches: 18
30. 0.000 4,774.112 ↓ 0.0 0 1,790,292 / 3

Append (cost=0.70..2.91 rows=1 width=29) (actual time=0.008..0.008 rows=0 loops=1,790,292)

31. 4,774.112 4,774.112 ↓ 0.0 0 1,790,292 / 3

Index Scan using cashbasis_p1_pkey on cashbasis_p1 c_1 (cost=0.70..2.90 rows=1 width=29) (actual time=0.008..0.008 rows=0 loops=1,790,292)

  • Index Cond: ((company_id = 109287618.000000000) AND (tx_id = t_1.tx_id) AND (sequence = t_1.sequence))
  • Filter: ((date(cash_date) >= '2020-01-01'::date) AND (date(cash_date) <= '2020-01-29'::date))
  • Rows Removed by Filter: 1
32. 0.000 0.000 ↓ 0.0 0 / 3

Hash (cost=345.48..345.48 rows=44 width=13) (never executed)

33. 0.000 0.000 ↓ 0.0 0 / 3

Index Scan using accounts_pk on accounts a_1 (cost=0.56..345.48 rows=44 width=13) (never executed)

  • Index Cond: (company_id = 109287618.000000000)
  • Filter: (account_type_id = '10'::numeric)
Planning time : 2.697 ms
Execution time : 7,628.794 ms