explain.depesz.com

PostgreSQL's explain analyze made readable

Result: eqcb

Settings
# exclusive inclusive rows x rows loops node
1. 0.215 33.450 ↑ 1.0 200 1

GroupAggregate (cost=10,029.37..10,059.81 rows=200 width=200) (actual time=33.245..33.450 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))
2. 0.075 33.235 ↑ 3.3 205 1

Sort (cost=10,029.37..10,031.08 rows=686 width=1,125) (actual time=33.223..33.235 rows=205 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: 41kB
3. 0.056 33.160 ↑ 3.3 205 1

Hash Left Join (cost=9,549.75..9,997.05 rows=686 width=1,125) (actual time=31.952..33.160 rows=205 loops=1)

  • Hash Cond: (ri.egais_status_id = return_status.id)
4. 0.113 33.085 ↑ 3.3 205 1

Nested Loop Left Join (cost=9,548.30..9,993.46 rows=686 width=617) (actual time=31.916..33.085 rows=205 loops=1)

5. 0.213 32.972 ↑ 3.3 205 1

Hash Left Join (cost=9,548.02..9,732.69 rows=686 width=617) (actual time=31.906..32.972 rows=205 loops=1)

  • Hash Cond: (rest.id = return_item.rests_item_id)
6. 0.041 18.420 ↑ 1.8 200 1

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

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

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

8. 0.092 18.259 ↑ 1.8 200 1

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

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

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

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

Sort (cost=6,687.17..6,687.98 rows=324 width=1,091) (actual time=8.372..8.432 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.284 7.982 ↓ 3.1 1,009 1

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

12. 0.438 2.653 ↓ 3.1 1,009 1

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

13. 0.039 1.015 ↑ 1.0 200 1

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

14. 0.576 0.576 ↑ 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.036..0.576 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 5.045 ↑ 1.0 1 1,009

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

18. 0.000 4.036 ↑ 1.0 1 1,009

Nested Loop Left Join (cost=0.56..3.13 rows=1 width=548) (actual time=0.004..0.004 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.002..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. 3.820 8.965 ↑ 1.0 20,773 1

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

  • Buckets: 32768 Batches: 1 Memory Usage: 1393kB
23. 5.145 5.145 ↑ 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.009..5.145 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.004 0.015 ↓ 1.1 21 1

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

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

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

27. 5.711 14.339 ↑ 1.4 28,242 1

Hash (cost=1,078.80..1,078.80 rows=39,680 width=16) (actual time=14.339..14.339 rows=28,242 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 1836kB
28. 8.628 8.628 ↑ 1.0 39,679 1

Seq Scan on return_invoice_item return_item (cost=0.00..1,078.80 rows=39,680 width=16) (actual time=0.006..8.628 rows=39,679 loops=1)

29. 0.000 0.000 ↓ 0.0 0 205

Index Scan using return_invoice_pkey on return_invoice ri (cost=0.28..0.38 rows=1 width=16) (actual time=0.000..0.000 rows=0 loops=205)

  • Index Cond: (return_item.return_invoice_id = id)
30. 0.009 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
31. 0.010 0.010 ↓ 1.1 21 1

Seq Scan on egais_status return_status (cost=0.00..1.20 rows=20 width=524) (actual time=0.007..0.010 rows=21 loops=1)

Planning time : 1.993 ms
Execution time : 33.617 ms