explain.depesz.com

PostgreSQL's explain analyze made readable

Result: LEpd

Settings
# exclusive inclusive rows x rows loops node
1. 35.066 57.670 ↓ 0.0 0 1

Update on rests_item (cost=8,146.47..9,851.59 rows=200 width=2,289) (actual time=57.670..57.670 rows=0 loops=1)

2. 0.233 22.604 ↑ 1.0 200 1

Nested Loop (cost=8,146.47..9,851.59 rows=200 width=2,289) (actual time=20.800..22.604 rows=200 loops=1)

3. 0.149 21.371 ↑ 1.0 200 1

Subquery Scan on sums (cost=8,146.04..8,160.09 rows=200 width=232) (actual time=20.766..21.371 rows=200 loops=1)

4. 0.437 21.222 ↑ 1.0 200 1

GroupAggregate (cost=8,146.04..8,158.09 rows=200 width=168) (actual time=20.757..21.222 rows=200 loops=1)

  • Group Key: rest.id, (sum(CASE WHEN ((((egais_status_act_store.code)::text = ANY ('{draft,send_error,sent_to_egais,act_rejected_in_egais,waiting_for_send,egais_error,act_repealed_in_egais}'::text[])) OR (((egais_status_act_store.code)::text = ANY ('{act_accepted_in_egais,accepted_in_egais}'::text[])) AND (act.ticket_date > lp.rests_report_date))) AND ((act_item.egais_register)::text = 'FIRST'::text)) THEN act_item.quantity ELSE '0'::numeric END)), (sum(CASE WHEN ((((egais_status_act_shop.code)::text = ANY ('{draft,send_error,sent_to_egais,act_rejected_in_egais,waiting_for_send,egais_error,act_repealed_in_egais}'::text[])) OR (((egais_status_act_shop.code)::text = ANY ('{act_accepted_in_egais,accepted_in_egais}'::text[])) AND (act.shop_ticket_date > lp.rests_shop_report_date))) AND ((act_item.egais_register)::text = 'SECOND'::text)) THEN act_item.quantity ELSE '0'::numeric END))
5. 0.103 20.785 ↑ 1.8 200 1

Sort (cost=8,146.04..8,146.95 rows=364 width=609) (actual time=20.741..20.785 rows=200 loops=1)

  • Sort Key: rest.id, (sum(CASE WHEN ((((egais_status_act_store.code)::text = ANY ('{draft,send_error,sent_to_egais,act_rejected_in_egais,waiting_for_send,egais_error,act_repealed_in_egais}'::text[])) OR (((egais_status_act_store.code)::text = ANY ('{act_accepted_in_egais,accepted_in_egais}'::text[])) AND (act.ticket_date > lp.rests_report_date))) AND ((act_item.egais_register)::text = 'FIRST'::text)) THEN act_item.quantity ELSE '0'::numeric END)), (sum(CASE WHEN ((((egais_status_act_shop.code)::text = ANY ('{draft,send_error,sent_to_egais,act_rejected_in_egais,waiting_for_send,egais_error,act_repealed_in_egais}'::text[])) OR (((egais_status_act_shop.code)::text = ANY ('{act_accepted_in_egais,accepted_in_egais}'::text[])) AND (act.shop_ticket_date > lp.rests_shop_report_date))) AND ((act_item.egais_register)::text = 'SECOND'::text)) THEN act_item.quantity ELSE '0'::numeric END))
  • Sort Method: quicksort Memory: 40kB
6. 0.055 20.682 ↑ 1.8 200 1

Hash Left Join (cost=7,973.22..8,130.55 rows=364 width=609) (actual time=19.647..20.682 rows=200 loops=1)

  • Hash Cond: (mov.egais_status_id = egais_status_mov.id)
7. 0.107 20.608 ↑ 1.8 200 1

Nested Loop Left Join (cost=7,971.77..8,127.95 rows=364 width=101) (actual time=19.606..20.608 rows=200 loops=1)

8. 0.213 20.501 ↑ 1.8 200 1

Hash Left Join (cost=7,971.49..8,007.12 rows=364 width=93) (actual time=19.593..20.501 rows=200 loops=1)

  • Hash Cond: (rest.id = mov_item.rests_item_id)
9. 0.784 11.328 ↑ 1.6 200 1

GroupAggregate (cost=6,687.17..6,707.42 rows=324 width=96) (actual time=10.496..11.328 rows=200 loops=1)

  • Group Key: rest.id, lp.rests_report_date, lp.rests_shop_report_date
10. 0.457 10.544 ↓ 3.1 1,009 1

Sort (cost=6,687.17..6,687.98 rows=324 width=1,091) (actual time=10.477..10.544 rows=1,009 loops=1)

  • Sort Key: rest.id, lp.rests_report_date, lp.rests_shop_report_date
  • Sort Method: quicksort Memory: 166kB
11. 0.096 10.087 ↓ 3.1 1,009 1

Nested Loop Left Join (cost=1.84..6,673.66 rows=324 width=1,091) (actual time=0.066..10.087 rows=1,009 loops=1)

12. 0.465 2.928 ↓ 3.1 1,009 1

Nested Loop Left Join (cost=1.15..5,606.28 rows=324 width=51) (actual time=0.056..2.928 rows=1,009 loops=1)

13. 0.080 1.263 ↑ 1.0 200 1

Nested Loop Left Join (cost=0.72..2,985.95 rows=200 width=32) (actual time=0.049..1.263 rows=200 loops=1)

14. 0.783 0.783 ↑ 1.0 200 1

Index Scan using rests_item_pkey on rests_item rest (cost=0.43..1,689.45 rows=200 width=16) (actual time=0.041..0.783 rows=200 loops=1)

  • Index Cond: (id = ANY ('{2543139,2742828,1994776,1595401,2746942,2344962,2495492,1318972,2754560,2445332,1599018,2755096,2416145,2354709,2441235,2145816,1554477,2145818,2145819,1318952,2755095,2235491,2518628,2628202,2628203,1707100,2653793,2682466,2681976,2717822,2511484,2511485,2511483,2705481,2705480,2705482,2753103,2705477,2705476,2705479,2705478,1576556,2339419,2753104,1380500,1633945,1598618,2375335,1633948,2447009,1598623,2447010,1618568,1654923,1654922,1783436,1708677,2725513,2091193,2412674,2303620,2286738,2238096,1999530,2238102,1686703,2238100,2238101,2419859,2286744,2445982,2655380,2644629,2644630,2327783,2222312,2710240,2222315,2720483,2222314,2720482,2302701,2222318,2512626,2715378,1521865,1692871,1521864,2320067,2320066,2320065,2320071,2320070,2320075,2320074,2320073,2738883,2320079,2320078,2320077,2320076,2174160,2354385,1612011,2730717,2730719,2509521,2162908,2591449,2162910,2710230,2500900,2500901,1612572,2500899,2543404,2712888,2700593,2498879,2700592,2351367,2580239,2580238,2351368,2580234,2499849,2546462,1608997,2202983,2202982,2339691,2339695,2421096,2339699,2483573,2339698,2483572,2339696,2339702,2483571,1650499,1650501,1650503,2519928,2259266,1794410,2506580,2198354,2506581,2506578,2198356,2506579,1605985,2582875,2710869,2472792,1664411,2460071,2327968,1664413,2648505,1620875,2006408,2112385,2323329,2459015,2297230,1645992,1645996,2614686,2614685,2141084,1318826,2141086,2341349,1792979,1631698,1631699,2384361,2591720,2580471,2384375,2388977,2069443,2300927,2411460,1428983,2400710,2476993,2528706,2411457,2411458,2411459,2520012,2551756,2411465,2318285,1730037,1660911,2246110}'::bigint[]))
15. 0.400 0.400 ↑ 1.0 1 200

Index Scan using legal_person_pkey on legal_person lp (cost=0.29..6.48 rows=1 width=24) (actual time=0.002..0.002 rows=1 loops=200)

  • Index Cond: (rest.legal_person_id = id)
16. 1.200 1.200 ↑ 1.2 5 200

Index Scan using idx_egais_act_item_rests_item_id on egais_act_item act_item (cost=0.43..13.04 rows=6 width=27) (actual time=0.003..0.006 rows=5 loops=200)

  • Index Cond: (rests_item_id = rest.id)
17. 1.009 7.063 ↑ 1.0 1 1,009

Nested Loop Left Join (cost=0.70..3.28 rows=1 width=1,056) (actual time=0.006..0.007 rows=1 loops=1,009)

18. 2.018 6.054 ↑ 1.0 1 1,009

Nested Loop Left Join (cost=0.56..3.13 rows=1 width=548) (actual time=0.006..0.006 rows=1 loops=1,009)

19. 3.027 3.027 ↑ 1.0 1 1,009

Index Scan using egais_act_pkey on egais_act act (cost=0.42..2.97 rows=1 width=40) (actual time=0.003..0.003 rows=1 loops=1,009)

  • Index Cond: (act_item.egais_act_id = id)
20. 1.009 1.009 ↑ 1.0 1 1,009

Index Scan using egais_status_pkey on egais_status egais_status_act_store (cost=0.14..0.16 rows=1 width=524) (actual time=0.001..0.001 rows=1 loops=1,009)

  • Index Cond: (act.store_act_status_id = id)
21. 0.000 0.000 ↓ 0.0 0 1,009

Index Scan using egais_status_pkey on egais_status egais_status_act_shop (cost=0.14..0.16 rows=1 width=524) (actual time=0.000..0.000 rows=0 loops=1,009)

  • Index Cond: (act.shop_act_status_id = id)
22. 4.093 8.960 ↑ 1.0 20,773 1

Hash (cost=1,023.03..1,023.03 rows=20,903 width=21) (actual time=8.960..8.960 rows=20,773 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 1393kB
23. 4.867 4.867 ↑ 1.0 20,773 1

Seq Scan on movement_invoice_item mov_item (cost=0.00..1,023.03 rows=20,903 width=21) (actual time=0.010..4.867 rows=20,773 loops=1)

24. 0.000 0.000 ↓ 0.0 0 200

Index Scan using movement_invoice_pkey on movement_invoice mov (cost=0.28..0.33 rows=1 width=24) (actual time=0.000..0.000 rows=0 loops=200)

  • Index Cond: (mov_item.movement_invoice_id = id)
25. 0.007 0.019 ↓ 1.1 21 1

Hash (cost=1.20..1.20 rows=20 width=524) (actual time=0.019..0.019 rows=21 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
26. 0.012 0.012 ↓ 1.1 21 1

Seq Scan on egais_status egais_status_mov (cost=0.00..1.20 rows=20 width=524) (actual time=0.009..0.012 rows=21 loops=1)

27. 1.000 1.000 ↑ 1.0 1 200

Index Scan using rests_item_pkey on rests_item (cost=0.43..8.45 rows=1 width=2,139) (actual time=0.005..0.005 rows=1 loops=200)

  • Index Cond: (id = sums.rests_id)
Planning time : 1.837 ms
Execution time : 57.881 ms