explain.depesz.com

PostgreSQL's explain analyze made readable

Result: bm3q

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 12,019.799 ↓ 8.5 17 1

Limit (cost=109,313.23..1,315,820.27 rows=2 width=293) (actual time=3,020.553..12,019.799 rows=17 loops=1)

2. 57.251 12,019.796 ↓ 8.5 17 1

Subquery Scan on stockcover0_ (cost=109,313.23..1,315,820.27 rows=2 width=293) (actual time=3,020.552..12,019.796 rows=17 loops=1)

  • Filter: ((stockcover0_.planned_production_date >= '2020-09-01'::date) AND (stockcover0_.planned_production_date < '2020-09-21'::date) AND (lower((stockcover0_.name_default)::text) ~~ '%%'::text) AND (lower((stockcover0_.supplier_name)::text) ~~ '%%'::text) AND (lower((stockcover0_.package_gtin)::text) ~~ '7680380960366'::text))
  • Rows Removed by Filter: 324,578
3. 1,109.574 11,962.545 ↓ 3.3 324,595 1

WindowAgg (cost=109,313.23..1,312,830.89 rows=99,646 width=293) (actual time=1,819.166..11,962.545 rows=324,595 loops=1)

4. 602.270 4,036.476 ↓ 3.3 324,595 1

Finalize GroupAggregate (cost=109,313.23..151,207.65 rows=99,646 width=125) (actual time=1,819.092..4,036.476 rows=324,595 loops=1)

  • Group Key: st.package_gtin, st.package_pharmacode, st.name_default, st.dosage_id, st.supplier_name, st.package_size, st.production_date, st.planned_production_date
5. 585.080 3,434.206 ↓ 2.1 415,950 1

Gather Merge (cost=109,313.23..144,979.77 rows=199,292 width=125) (actual time=1,819.078..3,434.206 rows=415,950 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
6. 372.426 2,849.126 ↓ 1.4 138,650 3 / 3

Partial GroupAggregate (cost=108,313.21..120,976.51 rows=99,646 width=125) (actual time=1,787.915..2,849.126 rows=138,650 loops=3)

  • Group Key: st.package_gtin, st.package_pharmacode, st.name_default, st.dosage_id, st.supplier_name, st.package_size, st.production_date, st.planned_production_date
7. 2,264.930 2,476.700 ↑ 1.2 332,152 3 / 3

Sort (cost=108,313.21..109,351.18 rows=415,190 width=103) (actual time=1,787.517..2,476.700 rows=332,152 loops=3)

  • Sort Key: st.package_gtin, st.package_pharmacode, st.name_default, st.dosage_id, st.supplier_name, st.package_size, st.production_date, st.planned_production_date
  • Sort Method: external merge Disk: 38,544kB
8. 211.770 211.770 ↑ 1.2 332,152 3 / 3

Parallel Seq Scan on stock_need st (cost=0.00..46,860.90 rows=415,190 width=103) (actual time=0.060..211.770 rows=332,152 loops=3)

9.          

SubPlan (for WindowAgg)

10. 324.595 1,622.975 ↑ 1.0 1 324,595

Aggregate (cost=2.31..2.31 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=324,595)

11. 320.374 1,298.380 ↓ 0.0 0 324,595

Nested Loop (cost=0.00..2.30 rows=1 width=32) (actual time=0.004..0.004 rows=0 loops=324,595)

  • Join Filter: (sl.location_settings_id = ls.id)
  • Rows Removed by Join Filter: 0
12. 973.785 973.785 ↓ 0.0 0 324,595

Seq Scan on stock_location sl (cost=0.00..1.12 rows=1 width=64) (actual time=0.003..0.003 rows=0 loops=324,595)

  • Filter: ((gtin)::text = (st.package_gtin)::text)
  • Rows Removed by Filter: 19
13. 4.221 4.221 ↓ 3.0 3 4,221

Seq Scan on stock_location_settings ls (cost=0.00..1.16 rows=1 width=32) (actual time=0.001..0.001 rows=3 loops=4,221)

  • Filter: ((aggregation_type)::text = 'PACKAGE'::text)
  • Rows Removed by Filter: 1
14. 0.000 1,298.380 ↑ 1.0 1 324,595

Aggregate (cost=2.31..2.31 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=324,595)

15. 311.932 1,298.380 ↓ 0.0 0 324,595

Nested Loop (cost=0.00..2.30 rows=1 width=32) (actual time=0.004..0.004 rows=0 loops=324,595)

  • Join Filter: (sl_1.location_settings_id = ls_1.id)
  • Rows Removed by Join Filter: 0
16. 973.785 973.785 ↓ 0.0 0 324,595

Seq Scan on stock_location sl_1 (cost=0.00..1.12 rows=1 width=64) (actual time=0.003..0.003 rows=0 loops=324,595)

  • Filter: ((gtin)::text = (st.package_gtin)::text)
  • Rows Removed by Filter: 19
17. 12.663 12.663 ↑ 1.0 1 4,221

Seq Scan on stock_location_settings ls_1 (cost=0.00..1.16 rows=1 width=32) (actual time=0.002..0.003 rows=1 loops=4,221)

  • Filter: ((aggregation_type)::text = 'DOSE'::text)
  • Rows Removed by Filter: 11
18. 0.000 1,298.380 ↑ 1.0 1 324,595

Aggregate (cost=2.31..2.31 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=324,595)

19. 311.932 1,298.380 ↓ 0.0 0 324,595

Nested Loop (cost=0.00..2.30 rows=1 width=32) (actual time=0.004..0.004 rows=0 loops=324,595)

  • Join Filter: (sl_2.location_settings_id = ls_2.id)
  • Rows Removed by Join Filter: 0
20. 973.785 973.785 ↓ 0.0 0 324,595

Seq Scan on stock_location sl_2 (cost=0.00..1.12 rows=1 width=64) (actual time=0.003..0.003 rows=0 loops=324,595)

  • Filter: ((gtin)::text = (st.package_gtin)::text)
  • Rows Removed by Filter: 19
21. 12.663 12.663 ↑ 1.0 1 4,221

Seq Scan on stock_location_settings ls_2 (cost=0.00..1.16 rows=1 width=32) (actual time=0.002..0.003 rows=1 loops=4,221)

  • Filter: ((aggregation_type)::text = 'CANISTER'::text)
  • Rows Removed by Filter: 12
22. 0.000 1,298.380 ↑ 1.0 1 324,595

Aggregate (cost=2.31..2.31 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=324,595)

23. 311.932 1,298.380 ↓ 0.0 0 324,595

Nested Loop (cost=0.00..2.30 rows=1 width=32) (actual time=0.004..0.004 rows=0 loops=324,595)

  • Join Filter: (sl_3.location_settings_id = ls_3.id)
  • Rows Removed by Join Filter: 0
24. 973.785 973.785 ↓ 0.0 0 324,595

Seq Scan on stock_location sl_3 (cost=0.00..1.12 rows=1 width=64) (actual time=0.003..0.003 rows=0 loops=324,595)

  • Filter: ((gtin)::text = (st.package_gtin)::text)
  • Rows Removed by Filter: 19
25. 12.663 12.663 ↓ 2.0 2 4,221

Seq Scan on stock_location_settings ls_3 (cost=0.00..1.16 rows=1 width=32) (actual time=0.002..0.003 rows=2 loops=4,221)

  • Filter: ((aggregation_type)::text = 'PRODUCTION'::text)
  • Rows Removed by Filter: 11
26. 0.000 1,298.380 ↑ 1.0 1 324,595

Aggregate (cost=2.38..2.38 rows=1 width=32) (actual time=0.004..0.004 rows=1 loops=324,595)

27. 320.374 1,298.380 ↓ 0.0 0 324,595

Nested Loop (cost=0.00..2.37 rows=1 width=32) (actual time=0.004..0.004 rows=0 loops=324,595)

  • Join Filter: (sl_4.location_settings_id = ls_4.id)
  • Rows Removed by Join Filter: 0
28. 973.785 973.785 ↓ 0.0 0 324,595

Seq Scan on stock_location sl_4 (cost=0.00..1.12 rows=1 width=64) (actual time=0.003..0.003 rows=0 loops=324,595)

  • Filter: ((gtin)::text = (st.package_gtin)::text)
  • Rows Removed by Filter: 19
29. 4.221 4.221 ↑ 1.3 3 4,221

Seq Scan on stock_location_settings ls_4 (cost=0.00..1.20 rows=4 width=32) (actual time=0.001..0.001 rows=3 loops=4,221)

  • Filter: ((aggregation_type)::text = ANY ('{PACKAGE,DOSE,CANISTER,PRODUCTION}'::text[]))
Planning time : 5.106 ms