explain.depesz.com

PostgreSQL's explain analyze made readable

Result: bWBA

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 24,350.944 ↑ 248.2 5 1

Sort (cost=2,513,218.03..2,513,221.13 rows=1,241 width=96) (actual time=24,350.944..24,350.944 rows=5 loops=1)

  • Sort Key: (sum(dad.rank))
  • Sort Method: quicksort Memory: 25kB
2. 0.012 24,350.937 ↑ 248.2 5 1

GroupAggregate (cost=2,513,008.44..2,513,154.26 rows=1,241 width=96) (actual time=24,350.931..24,350.937 rows=5 loops=1)

  • Group Key: (CASE WHEN (dad.rank > 10) THEN 'OUTROS'::text ELSE dad.nome END)
3. 0.006 24,350.925 ↑ 2,482.0 5 1

Sort (cost=2,513,008.44..2,513,039.47 rows=12,410 width=72) (actual time=24,350.924..24,350.925 rows=5 loops=1)

  • Sort Key: (CASE WHEN (dad.rank > 10) THEN 'OUTROS'::text ELSE dad.nome END)
  • Sort Method: quicksort Memory: 25kB
4. 0.003 24,350.919 ↑ 2,482.0 5 1

Subquery Scan on dad (cost=2,511,761.28..2,512,164.61 rows=12,410 width=72) (actual time=24,350.911..24,350.919 rows=5 loops=1)

5. 0.017 24,350.916 ↑ 2,482.0 5 1

WindowAgg (cost=2,511,761.28..2,512,009.48 rows=12,410 width=72) (actual time=24,350.909..24,350.916 rows=5 loops=1)

6. 0.010 24,350.899 ↑ 2,482.0 5 1

Sort (cost=2,511,761.28..2,511,792.31 rows=12,410 width=64) (actual time=24,350.899..24,350.899 rows=5 loops=1)

  • Sort Key: (sum(COALESCE(((vei.value ->> 'vei_vl_quantidade'::text))::numeric, '0'::numeric))) DESC
  • Sort Method: quicksort Memory: 25kB
7. 0.000 24,350.889 ↑ 2,482.0 5 1

Finalize GroupAggregate (cost=2,506,098.03..2,510,917.45 rows=12,410 width=64) (actual time=24,344.760..24,350.889 rows=5 loops=1)

  • Group Key: ((ven.ven_js_dados ->> 'tur_ds_turno'::text))
8. 80.014 24,420.965 ↑ 1,654.7 15 1

Gather Merge (cost=2,506,098.03..2,510,545.15 rows=24,820 width=64) (actual time=24,341.138..24,420.965 rows=15 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
9. 10.728 24,340.951 ↑ 2,482.0 5 3 / 3

Partial GroupAggregate (cost=2,505,098.01..2,506,680.29 rows=12,410 width=64) (actual time=24,333.951..24,340.951 rows=5 loops=3)

  • Group Key: ((ven.ven_js_dados ->> 'tur_ds_turno'::text))
10. 22.412 24,330.223 ↑ 6.2 15,119 3 / 3

Sort (cost=2,505,098.01..2,505,330.70 rows=93,075 width=64) (actual time=24,328.685..24,330.223 rows=15,119 loops=3)

  • Sort Key: ((ven.ven_js_dados ->> 'tur_ds_turno'::text))
  • Sort Method: quicksort Memory: 31078kB
  • Worker 0: Sort Method: quicksort Memory: 30691kB
  • Worker 1: Sort Method: quicksort Memory: 30743kB
11. 124.117 24,307.811 ↑ 6.2 15,119 3 / 3

Nested Loop (cost=35,131.37..2,497,416.48 rows=93,075 width=64) (actual time=1,415.490..24,307.811 rows=15,119 loops=3)

12. 23,815.878 24,068.367 ↓ 2.2 11,533 3 / 3

Parallel Bitmap Heap Scan on venda ven (cost=35,131.37..2,475,569.01 rows=5,171 width=1,413) (actual time=1,415.400..24,068.367 rows=11,533 loops=3)

  • Recheck Cond: ((ven_cd_unidade_negocio = ANY ('{183,185,180}'::integer[])) AND (ven_fl_cancelada = 'N'::bpchar))
  • Filter: ((((ven_js_dados ->> 'cai_dt_movimento'::text))::date <= CURRENT_DATE) AND (((ven_js_dados ->> 'cai_dt_movimento'::text))::date >= (CURRENT_DATE - '30 days'::interval)))
  • Rows Removed by Filter: 765303
  • Heap Blocks: exact=580654
13. 252.489 252.489 ↑ 1.1 2,330,507 1 / 3

Bitmap Index Scan on venda_ven_cd_unidade_negocio_ven_fl_cancelada_ven_dt_fiscal_ven (cost=0.00..35,128.26 rows=2,481,956 width=0) (actual time=757.466..757.466 rows=2,330,507 loops=1)

  • Index Cond: ((ven_cd_unidade_negocio = ANY ('{183,185,180}'::integer[])) AND (ven_fl_cancelada = 'N'::bpchar))
14. 115.327 115.327 ↑ 18.0 1 34,598 / 3

Function Scan on jsonb_array_elements vei (cost=0.01..4.00 rows=18 width=32) (actual time=0.010..0.010 rows=1 loops=34,598)

  • Filter: (((value ->> 'pro_cd_produto_grupo'::text))::integer = ANY ('{1653,1624,1657,1655,1630,1633,1634,1637,1619,1638,1641,1621,1642,1643,1620,1646,1651,1658}'::integer[]))
Planning time : 1.013 ms
Execution time : 24,421.201 ms