explain.depesz.com

A tool for finding a real cause for slow queries.

Result: lpU : stock_usr_lot

options
Did it help? Consider supporting us - Bitcoin address: 12v2hUztAk2LgzQ9H9LMwuU32urHMjZQnq
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=25296.31..277917.17 rows=610670 width=2309) (actual time=.. rows= loops=)

  • Merge Cond: (docin.lot = docout.lotout)
  • Filter: ((((docin.cantrec)::double precision - COALESCE((sum(CASE ((docout.tipdoc)::text ~~ 'pro%'::text) WHEN CASE_TEST_EXPR THEN 0::double precision ELSE (docout.cantout)::double precision END)), 0::double precision)) > 1e-05::double precision) OR (COALESCE((sum(CASE (((docout.tipdoc)::text = 'tvliv'::text) AND ((docout.nrdocsec)::text <> 'validat'::text)) WHEN CASE_TEST_EXPR THEN (docout.cantout)::double precision ELSE 0::double precision END)), 0::double precision) <> 0::double precision) OR (COALESCE((sum(CASE ((docout.tipdoc)::text ~~ 'pro%'::text) WHEN CASE_TEST_EXPR THEN (docout.cantout)::double precision ELSE 0::double precision END)), 0::double precision) <> 0::double precision))
2.          

Initplan (forMerge Left Join)

3. 0.000 0.000 ↓ 0.0

Seq Scan on myvars (cost=0.00..6.23 rows=1 width=12) (actual time=.. rows= loops=)

  • Filter: (lower((username)::text) = lower((("current_user"())::character varying)::text))
4. 0.000 0.000 ↓ 0.0

Sort (cost=25290.08..25304.32 rows=5694 width=2285) (actual time=.. rows= loops=)

  • Sort Key: docin.lot
5. 0.000 0.000 ↓ 0.0

Nested Loop (cost=53.19..13685.91 rows=5694 width=2285) (actual time=.. rows= loops=)

6. 0.000 0.000 ↓ 0.0

Hash Join (cost=53.19..11969.07 rows=5694 width=805) (actual time=.. rows= loops=)

  • Hash Cond: (docin.gestid = public.mygestiuni.idgest)
7. 0.000 0.000 ↓ 0.0

Hash Join (cost=42.15..11155.34 rows=54236 width=451) (actual time=.. rows= loops=)

  • Hash Cond: (docin.gestid = public.mygestiuni.idgest)
8.          

Initplan (forHash Join)

9. 0.000 0.000 ↓ 0.0

Seq Scan on myvars (cost=0.00..6.23 rows=1 width=12) (actual time=.. rows= loops=)

  • Filter: (lower((username)::text) = lower((("current_user"())::character varying)::text))
10. 0.000 0.000 ↓ 0.0

Seq Scan on myvars (cost=0.00..6.23 rows=1 width=4) (actual time=.. rows= loops=)

  • Filter: (lower((username)::text) = lower((("current_user"())::character varying)::text))
11. 0.000 0.000 ↓ 0.0

Seq Scan on myvars (cost=0.00..6.23 rows=1 width=4) (actual time=.. rows= loops=)

  • Filter: (lower((username)::text) = lower((("current_user"())::character varying)::text))
12. 0.000 0.000 ↓ 0.0

Seq Scan on myvars (cost=0.00..6.23 rows=1 width=1) (actual time=.. rows= loops=)

  • Filter: (lower((username)::text) = lower((("current_user"())::character varying)::text))
13. 0.000 0.000 ↓ 0.0

Seq Scan on myvars (cost=0.00..6.23 rows=1 width=1) (actual time=.. rows= loops=)

  • Filter: (lower((username)::text) = lower((("current_user"())::character varying)::text))
14. 0.000 0.000 ↓ 0.0

Seq Scan on docin (cost=0.00..9221.39 rows=185951 width=451) (actual time=.. rows= loops=)

  • Filter: (valid AND ((tipdoc)::text !~~ 'pro%'::text))
15. 0.000 0.000 ↓ 0.0

Hash (cost=10.89..10.89 rows=10 width=8) (actual time=.. rows= loops=)

16. 0.000 0.000 ↓ 0.0

Hash Join (cost=6.45..10.89 rows=10 width=8) (actual time=.. rows= loops=)

  • Hash Cond: (public.user_gest.gest = public.mygestiuni.idgest)
17. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on user_gest (cost=4.41..8.68 rows=21 width=4) (actual time=.. rows= loops=)

  • Recheck Cond: ((username)::text = ($1)::text)
18. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idx_usergest_username (cost=0.00..4.41 rows=21 width=0) (actual time=.. rows= loops=)

  • Index Cond: ((username)::text = ($1)::text)
19. 0.000 0.000 ↓ 0.0

Hash (cost=1.81..1.81 rows=18 width=4) (actual time=.. rows= loops=)

20. 0.000 0.000 ↓ 0.0

Seq Scan on mygestiuni (cost=0.00..1.81 rows=18 width=4) (actual time=.. rows= loops=)

  • Filter: CASE ($2 <> 0) WHEN CASE_TEST_EXPR THEN (idgest = $3) ELSE CASE (($4)::text <> ''::text) WHEN CASE_TEST_EXPR THEN ((grupagestiune)::text = ($5)::text) ELSE (idgest <> 0) END END
21. 0.000 0.000 ↓ 0.0

Hash (cost=10.77..10.77 rows=21 width=350) (actual time=.. rows= loops=)

22. 0.000 0.000 ↓ 0.0

Hash Join (cost=6.22..10.77 rows=21 width=350) (actual time=.. rows= loops=)

  • Hash Cond: (public.user_gest.gest = public.mygestiuni.idgest)
23. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on user_gest (cost=4.41..8.68 rows=21 width=4) (actual time=.. rows= loops=)

  • Recheck Cond: ((username)::text = ($0)::text)
24. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on idx_usergest_username (cost=0.00..4.41 rows=21 width=0) (actual time=.. rows= loops=)

  • Index Cond: ((username)::text = ($0)::text)
25. 0.000 0.000 ↓ 0.0

Hash (cost=1.36..1.36 rows=36 width=346) (actual time=.. rows= loops=)

26. 0.000 0.000 ↓ 0.0

Seq Scan on mygestiuni (cost=0.00..1.36 rows=36 width=346) (actual time=.. rows= loops=)

27. 0.000 0.000 ↓ 0.0

Index Scan using idxart_idart on articole (cost=0.00..0.29 rows=1 width=1480) (actual time=.. rows= loops=)

  • Index Cond: (idart = docin.artid)
28. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..226694.57 rows=21447 width=28) (actual time=.. rows= loops=)

29. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.00..226426.48 rows=21447 width=18) (actual time=.. rows= loops=)

30. 0.000 0.000 ↓ 0.0

Index Scan using idxdocoutlotout on docout (cost=0.00..184937.18 rows=1500903 width=18) (actual time=.. rows= loops=)

  • Filter: valid