explain.depesz.com

PostgreSQL's explain analyze made readable

Result: tqZf

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 7,811.326 ↓ 0.0 0 1

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

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

Merge Right Join (cost=5,507,747.96..5,514,094.43 rows=93 width=68) (actual time=7,811.323..7,811.323 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 2,031.111 ↓ 0.0 0 1

Finalize GroupAggregate (cost=3,621,629.45..3,627,069.93 rows=32,860 width=61) (actual time=2,031.111..2,031.111 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.782 2,031.181 ↓ 0.0 0 1

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

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

Partial GroupAggregate (cost=3,620,629.42..3,621,348.25 rows=13,692 width=61) (actual time=2,026.399..2,026.399 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 2,026.398 ↓ 0.0 0 3 / 3

Sort (cost=3,620,629.42..3,620,663.65 rows=13,692 width=35) (actual time=2,026.398..2,026.398 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 2,026.375 ↓ 0.0 0 3 / 3

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

8. 0.001 2,026.374 ↓ 0.0 0 3 / 3

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

  • Hash Cond: (c.account_id = a.account_id)
9. 0.001 2,026.373 ↓ 0.0 0 3 / 3

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

10. 2,026.372 2,026.372 ↓ 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=2,026.372..2,026.372 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.011 5,780.211 ↓ 0.0 0 1

Sort (cost=1,886,118.52..1,886,118.75 rows=93 width=21) (actual time=5,780.211..5,780.211 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.000 5,780.200 ↓ 0.0 0 1

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

17. 0.351 0.351 ↑ 1.0 31 1

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

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

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

19. 0.000 5,779.839 ↓ 0.0 0 1

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

20. 0.002 5,779.839 ↓ 0.0 0 1

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

21. 0.003 5,779.837 ↓ 0.0 0 1

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

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

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

  • Group Key: t_1.item_id
23. 6.293 5,781.431 ↓ 0.0 0 1

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

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

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

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

Sort (cost=1,884,587.02..1,884,594.24 rows=2,890 width=11) (actual time=5,775.137..5,775.137 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,775.120 ↓ 0.0 0 3 / 3

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

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

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

28. 47.560 618.131 ↓ 1.4 596,764 3 / 3

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

29. 570.571 570.571 ↓ 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..570.571 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.766 ms
Execution time : 7,813.194 ms