explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Fght

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 63,440.734 ↑ 40.0 5 1

Sort (cost=2,489,980.25..2,489,980.75 rows=200 width=96) (actual time=63,440.733..63,440.734 rows=5 loops=1)

  • Sort Key: (sum(dad.rank))
  • Sort Method: quicksort Memory: 25kB
2. 0.013 63,440.727 ↑ 40.0 5 1

GroupAggregate (cost=2,489,961.80..2,489,972.61 rows=200 width=96) (actual time=63,440.721..63,440.727 rows=5 loops=1)

  • Group Key: (CASE WHEN (dad.rank > 10) THEN 'OUTROS'::text ELSE dad.nome END)
3. 0.017 63,440.714 ↑ 146.2 5 1

Sort (cost=2,489,961.80..2,489,963.62 rows=731 width=72) (actual time=63,440.714..63,440.714 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.004 63,440.697 ↑ 146.2 5 1

Subquery Scan on dad (cost=2,489,903.27..2,489,927.02 rows=731 width=72) (actual time=63,440.689..63,440.697 rows=5 loops=1)

5. 0.027 63,440.693 ↑ 146.2 5 1

WindowAgg (cost=2,489,903.27..2,489,917.89 rows=731 width=72) (actual time=63,440.686..63,440.693 rows=5 loops=1)

6. 0.016 63,440.666 ↑ 146.2 5 1

Sort (cost=2,489,903.27..2,489,905.09 rows=731 width=64) (actual time=63,440.665..63,440.666 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 63,440.650 ↑ 146.2 5 1

Finalize GroupAggregate (cost=2,489,773.40..2,489,868.49 rows=731 width=64) (actual time=63,435.175..63,440.650 rows=5 loops=1)

  • Group Key: ((ven.ven_js_dados ->> 'tur_ds_turno'::text))
8. 1,790.196 65,149.446 ↑ 40.7 15 1

Gather Merge (cost=2,489,773.40..2,489,852.95 rows=610 width=64) (actual time=63,429.329..65,149.446 rows=15 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
9. 46.570 63,359.250 ↑ 61.0 5 3 / 3

Partial GroupAggregate (cost=2,488,773.37..2,488,782.52 rows=305 width=64) (actual time=63,345.384..63,359.250 rows=5 loops=3)

  • Group Key: ((ven.ven_js_dados ->> 'tur_ds_turno'::text))
10. 92.049 63,312.680 ↓ 49.6 15,119 3 / 3

Sort (cost=2,488,773.37..2,488,774.13 rows=305 width=64) (actual time=63,310.696..63,312.680 rows=15,119 loops=3)

  • Sort Key: ((ven.ven_js_dados ->> 'tur_ds_turno'::text))
  • Sort Method: quicksort Memory: 32,690kB
  • Worker 0: Sort Method: quicksort Memory: 30,071kB
  • Worker 1: Sort Method: quicksort Memory: 29,750kB
11. 177.943 63,220.631 ↓ 49.6 15,119 3 / 3

Nested Loop (cost=35,132.52..2,488,760.79 rows=305 width=64) (actual time=2,500.251..63,220.631 rows=15,119 loops=3)

12. 68.673 62,835.100 ↓ 678.4 11,533 3 / 3

Nested Loop (cost=35,132.51..2,488,688.96 rows=17 width=1,413) (actual time=2,500.188..62,835.100 rows=11,533 loops=3)

13. 62,131.469 62,604.970 ↓ 2.2 11,533 3 / 3

Parallel Bitmap Heap Scan on venda ven (cost=35,132.09..2,475,641.98 rows=5,171 width=1,421) (actual time=2,499.736..62,604.970 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: 765,303
  • Heap Blocks: exact=577,787
14. 473.501 473.501 ↑ 1.1 2,332,141 1 / 3

Bitmap Index Scan on venda_ven_cd_unidade_negocio_ven_fl_cancelada_ven_dt_fiscal_ven (cost=0.00..35,128.99 rows=2,482,030 width=0) (actual time=1,420.502..1,420.502 rows=2,332,141 loops=1)

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

Index Scan using caixa_pkey on caixa cai (cost=0.42..2.51 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=34,598)

  • Index Cond: (cai_cd_caixa = ven.ven_cd_caixa)
  • Filter: (ven.ven_cd_unidade_negocio = cai_cd_unidade_negocio)
16. 207.588 207.588 ↑ 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.018..0.018 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 : 5.233 ms
Execution time : 65,187.024 ms