explain.depesz.com

PostgreSQL's explain analyze made readable

Result: jqSb : Atlas

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 1,888.427 3,225,238.407 ↓ 32,472.5 64,945 1

Sort (cost=659,826.90..659,826.90 rows=2 width=2,648) (actual time=3,225,229.500..3,225,238.407 rows=64,945 loops=1)

  • Sort Key: a.datapiramide, a.nrdoc, a.nrguia, a.valor
  • Sort Method: quicksort Memory: 66,615kB
2. 57.656 3,223,349.980 ↓ 32,472.5 64,945 1

Subquery Scan on a (cost=2.68..659,826.89 rows=2 width=2,648) (actual time=339.953..3,223,349.980 rows=64,945 loops=1)

3. 45.250 3,223,292.324 ↓ 32,472.5 64,945 1

Append (cost=2.68..659,826.87 rows=2 width=546) (actual time=339.952..3,223,292.324 rows=64,945 loops=1)

4. 82.051 3,220,774.129 ↓ 64,945.0 64,945 1

Subquery Scan on *SELECT* 1 (cost=2.68..643,810.37 rows=1 width=521) (actual time=339.951..3,220,774.129 rows=64,945 loops=1)

5. 12,608.147 3,220,692.078 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..643,810.36 rows=1 width=521) (actual time=339.948..3,220,692.078 rows=64,945 loops=1)

  • Join Filter: ((mic.id_ctactb_cre)::text = (cc.id)::text)
  • Rows Removed by Join Filter: 118,070,010
6. 15,001.084 3,199,900.861 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..643,732.43 rows=1 width=460) (actual time=339.678..3,199,900.861 rows=64,945 loops=1)

  • Join Filter: ((mic.id_ctactb_deb)::text = (cd.id)::text)
  • Rows Removed by Join Filter: 118,070,010
7. 625,217.908 3,176,132.202 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..643,654.50 rows=1 width=400) (actual time=339.268..3,176,132.202 rows=64,945 loops=1)

  • Join Filter: ((mi.id_servico)::text = (s.id)::text)
  • Rows Removed by Join Filter: 4,312,607,780
8. 369.216 2,132,148.934 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..638,752.39 rows=1 width=359) (actual time=331.516..2,132,148.934 rows=64,945 loops=1)

  • Join Filter: ((prod.id_segmentacao)::text = (cob.id)::text)
  • Rows Removed by Join Filter: 991,532
9. 4,633.410 2,131,584.883 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..638,751.03 rows=1 width=354) (actual time=331.508..2,131,584.883 rows=64,945 loops=1)

  • Join Filter: ((mi.id_produto)::text = (prod.id)::text)
  • Rows Removed by Join Filter: 29,567,332
10. 307.482 2,123,769.168 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..638,720.77 rows=1 width=355) (actual time=331.320..2,123,769.168 rows=64,945 loops=1)

  • Join Filter: ((mod.id_tipocontratacao)::text = (tc.id)::text)
  • Rows Removed by Join Filter: 324,725
11. 295.377 2,123,331.796 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..638,719.63 rows=1 width=342) (actual time=331.315..2,123,331.796 rows=64,945 loops=1)

  • Join Filter: ((mod.id_modalidadecobranca)::text = (mc.id)::text)
  • Rows Removed by Join Filter: 129,890
12. 2,394.958 2,122,971.474 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..638,718.57 rows=1 width=333) (actual time=331.309..2,122,971.474 rows=64,945 loops=1)

  • Join Filter: ((c.id_mod_contrato)::text = (mod.id)::text)
  • Rows Removed by Join Filter: 15,716,690
13. 185.435 2,119,147.726 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=2.68..638,708.10 rows=1 width=332) (actual time=331.301..2,119,147.726 rows=64,945 loops=1)

14. 940.121 2,110,454.496 ↓ 64,945.0 64,945 1

Nested Loop Left Join (cost=1.84..638,696.29 rows=1 width=297) (actual time=331.220..2,110,454.496 rows=64,945 loops=1)

  • Join Filter: ((p.id_classe)::text = (pc.id)::text)
  • Rows Removed by Join Filter: 4,026,590
15. 1,549,845.422 2,109,059.760 ↓ 64,945.0 64,945 1

Nested Loop (cost=1.84..638,693.87 rows=1 width=284) (actual time=331.205..2,109,059.760 rows=64,945 loops=1)

  • Join Filter: ((mif.id)::text = (mic.id_movitem_financeiro)::text)
  • Rows Removed by Join Filter: 10,601,885,039
16. 4,419.411 4,419.411 ↓ 3.6 163,127 1

Seq Scan on movitem_composicao mic (cost=0.00..627,986.84 rows=45,445 width=144) (actual time=0.018..4,419.411 rows=163,127 loops=1)

  • Filter: ((date(dt_pir) >= '2020-05-01'::date) AND (date(dt_pir) <= '2020-05-31'::date))
  • Rows Removed by Filter: 9,959,181
17. 552,950.019 554,794.927 ↓ 7,221.3 64,992 163,127

Materialize (cost=1.84..4,571.98 rows=9 width=164) (actual time=0.000..3.401 rows=64,992 loops=163,127)

18. 46.651 1,844.908 ↓ 7,221.3 64,992 1

Nested Loop Left Join (cost=1.84..4,571.94 rows=9 width=164) (actual time=0.112..1,844.908 rows=64,992 loops=1)

19. 0.000 1,278.321 ↓ 7,221.3 64,992 1

Nested Loop (cost=1.55..4,520.27 rows=9 width=91) (actual time=0.094..1,278.321 rows=64,992 loops=1)

20. 13.180 47.807 ↓ 7,221.3 64,992 1

Nested Loop (cost=0.99..4,464.09 rows=9 width=53) (actual time=0.065..47.807 rows=64,992 loops=1)

21. 0.025 0.025 ↑ 1.0 1 1

Index Scan using idx_tabdocfin_nr_doc on tabdocfin f (cost=0.43..8.45 rows=1 width=35) (actual time=0.024..0.025 rows=1 loops=1)

  • Index Cond: (((id_emp)::text = '1'::text) AND ((nr_doc)::text = '8814904'::text))
22. 34.602 34.602 ↓ 40.1 64,992 1

Index Scan using movitem_financeiro_docfin_idx on movitem_financeiro mif (cost=0.56..4,439.42 rows=1,622 width=38) (actual time=0.039..34.602 rows=64,992 loops=1)

  • Index Cond: ((id_docfin)::text = (f.id)::text)
23. 1,234.848 1,234.848 ↑ 1.0 1 64,992

Index Scan using movitem_pk on movitem mi (cost=0.56..6.23 rows=1 width=70) (actual time=0.018..0.019 rows=1 loops=64,992)

  • Index Cond: ((id)::text = (mif.id_movitem)::text)
24. 519.936 519.936 ↑ 1.0 1 64,992

Index Scan using tabprestador_pk on tabprestador p (cost=0.29..5.73 rows=1 width=86) (actual time=0.008..0.008 rows=1 loops=64,992)

  • Index Cond: ((mi.id_prest)::text = (id)::text)
25. 454.615 454.615 ↑ 1.0 63 64,945

Seq Scan on tabprest_classe pc (cost=0.00..1.63 rows=63 width=33) (actual time=0.003..0.007 rows=63 loops=64,945)

26. 259.780 8,507.795 ↑ 1.0 1 64,945

Nested Loop Left Join (cost=0.84..11.80 rows=1 width=63) (actual time=0.123..0.131 rows=1 loops=64,945)

27. 4,351.315 4,351.315 ↑ 1.0 1 64,945

Index Scan using tabusuario_pk on tabusuario b (cost=0.42..5.90 rows=1 width=64) (actual time=0.062..0.067 rows=1 loops=64,945)

  • Index Cond: ((mi.id_uni_usu)::text = (id)::text)
28. 3,896.700 3,896.700 ↑ 1.0 1 64,945

Index Scan using tabusu_emp_pk on tabusu_emp c (cost=0.41..5.89 rows=1 width=24) (actual time=0.057..0.060 rows=1 loops=64,945)

  • Index Cond: ((b.id_contrato)::text = (id)::text)
29. 1,428.790 1,428.790 ↑ 1.0 243 64,945

Seq Scan on tabusu_emp_modelo mod (cost=0.00..7.43 rows=243 width=23) (actual time=0.002..0.022 rows=243 loops=64,945)

30. 64.945 64.945 ↑ 1.0 3 64,945

Seq Scan on tabusu_emp_modelo_modalidadecobranca mc (cost=0.00..1.03 rows=3 width=22) (actual time=0.001..0.001 rows=3 loops=64,945)

31. 129.890 129.890 ↑ 1.0 6 64,945

Seq Scan on tabusu_emp_modelo_tipocontratacao tc (cost=0.00..1.06 rows=6 width=25) (actual time=0.001..0.002 rows=6 loops=64,945)

32. 3,182.305 3,182.305 ↑ 1.0 456 64,945

Seq Scan on tabusu_produto prod (cost=0.00..24.56 rows=456 width=20) (actual time=0.002..0.049 rows=456 loops=64,945)

33. 194.835 194.835 ↑ 1.0 16 64,945

Seq Scan on tabusu_produto_segmentacao cob (cost=0.00..1.16 rows=16 width=17) (actual time=0.001..0.003 rows=16 loops=64,945)

34. 418,765.360 418,765.360 ↑ 1.0 66,405 64,945

Seq Scan on tabservico s (cost=0.00..4,072.05 rows=66,405 width=67) (actual time=0.003..6.448 rows=66,405 loops=64,945)

35. 8,767.575 8,767.575 ↑ 1.0 1,819 64,945

Seq Scan on tabctactb cd (cost=0.00..55.19 rows=1,819 width=76) (actual time=0.002..0.135 rows=1,819 loops=64,945)

36. 8,183.070 8,183.070 ↑ 1.0 1,819 64,945

Seq Scan on tabctactb cc (cost=0.00..55.19 rows=1,819 width=76) (actual time=0.001..0.126 rows=1,819 loops=64,945)

37. 0.003 2,472.945 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=2.81..16,016.49 rows=1 width=571) (actual time=2,472.945..2,472.945 rows=0 loops=1)

38. 0.005 2,472.942 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.81..16,016.48 rows=1 width=571) (actual time=2,472.942..2,472.942 rows=0 loops=1)

  • Join Filter: ((apc.id_ctactb_cre)::text = (cc_1.id)::text)
39. 0.004 2,472.937 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.81..15,938.54 rows=1 width=510) (actual time=2,472.937..2,472.937 rows=0 loops=1)

  • Join Filter: ((apc.id_ctactb_deb)::text = (cd_1.id)::text)
40. 0.004 2,472.933 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.81..15,860.62 rows=1 width=450) (actual time=2,472.933..2,472.933 rows=0 loops=1)

41. 0.003 2,472.929 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.40..15,855.33 rows=1 width=396) (actual time=2,472.929..2,472.929 rows=0 loops=1)

  • Join Filter: ((prod_1.id_segmentacao)::text = (cob_1.id)::text)
42. 0.004 2,472.926 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.40..15,853.97 rows=1 width=391) (actual time=2,472.926..2,472.926 rows=0 loops=1)

  • Join Filter: ((apc.id_produto)::text = (prod_1.id)::text)
43. 0.003 2,472.922 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.40..15,823.71 rows=1 width=391) (actual time=2,472.922..2,472.922 rows=0 loops=1)

  • Join Filter: ((mod_1.id_tipocontratacao)::text = (tc_1.id)::text)
44. 0.002 2,472.919 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.40..15,822.57 rows=1 width=378) (actual time=2,472.919..2,472.919 rows=0 loops=1)

  • Join Filter: ((mod_1.id_modalidadecobranca)::text = (mc_1.id)::text)
45. 0.005 2,472.917 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.40..15,821.51 rows=1 width=369) (actual time=2,472.917..2,472.917 rows=0 loops=1)

  • Join Filter: ((c_1.id_mod_contrato)::text = (mod_1.id)::text)
46. 0.002 2,472.912 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.40..15,811.04 rows=1 width=368) (actual time=2,472.912..2,472.912 rows=0 loops=1)

47. 0.008 2,472.910 ↓ 0.0 0 1

Nested Loop Left Join (cost=1.98..15,810.55 rows=1 width=369) (actual time=2,472.910..2,472.910 rows=0 loops=1)

48. 0.001 2,472.902 ↓ 0.0 0 1

Nested Loop Left Join (cost=1.56..15,802.51 rows=1 width=333) (actual time=2,472.902..2,472.902 rows=0 loops=1)

  • Join Filter: ((p_1.id_classe)::text = (pc_1.id)::text)
49. 0.001 2,472.901 ↓ 0.0 0 1

Nested Loop Left Join (cost=1.56..15,800.10 rows=1 width=320) (actual time=2,472.901..2,472.901 rows=0 loops=1)

50. 0.001 2,472.900 ↓ 0.0 0 1

Nested Loop (cost=1.27..15,799.78 rows=1 width=247) (actual time=2,472.900..2,472.900 rows=0 loops=1)

  • Join Filter: ((ap.id_ajuste)::text = (a_1.id)::text)
51. 0.148 2,472.899 ↓ 0.0 0 1

Nested Loop (cost=1.27..15,788.48 rows=1 width=226) (actual time=2,472.899..2,472.899 rows=0 loops=1)

52. 0.067 336.310 ↓ 51.0 51 1

Nested Loop (cost=0.85..13,576.26 rows=1 width=61) (actual time=334.662..336.310 rows=51 loops=1)

53. 0.101 0.101 ↑ 1.0 1 1

Index Scan using idx_tabdocfin_nr_doc on tabdocfin f_1 (cost=0.43..8.45 rows=1 width=35) (actual time=0.100..0.101 rows=1 loops=1)

  • Index Cond: (((id_emp)::text = '1'::text) AND ((nr_doc)::text = '8814904'::text))
54. 336.142 336.142 ↓ 2.3 51 1

Index Scan using idx_tabprest_ajuste_prest_docfin on tabprest_ajuste_prest ap (cost=0.42..13,567.59 rows=22 width=46) (actual time=334.543..336.142 rows=51 loops=1)

  • Index Cond: ((id_docfin)::text = (f_1.id)::text)
55. 2,136.441 2,136.441 ↓ 0.0 0 51

Index Scan using tabprest_ajuste_prest_composicao_ajuste_prestador_idx on tabprest_ajuste_prest_composicao apc (cost=0.42..2,212.21 rows=1 width=194) (actual time=41.891..41.891 rows=0 loops=51)

  • Index Cond: ((id_ajuste_prestador)::text = (ap.id)::text)
  • Filter: ((date(dt_pir) >= '2020-05-01'::date) AND (date(dt_pir) <= '2020-05-31'::date))
56. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabprest_ajuste a_1 (cost=0.00..7.80 rows=280 width=43) (never executed)

57. 0.000 0.000 ↓ 0.0 0

Index Scan using tabprestador_pk on tabprestador p_1 (cost=0.29..0.31 rows=1 width=86) (never executed)

  • Index Cond: ((ap.id_prestador)::text = (id)::text)
58. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabprest_classe pc_1 (cost=0.00..1.63 rows=63 width=33) (never executed)

59. 0.000 0.000 ↓ 0.0 0

Index Scan using tabusuario_pk on tabusuario b_1 (cost=0.42..8.03 rows=1 width=64) (never executed)

  • Index Cond: ((apc.id_beneficiario)::text = (id)::text)
60. 0.000 0.000 ↓ 0.0 0

Index Scan using tabusu_emp_pk on tabusu_emp c_1 (cost=0.41..0.47 rows=1 width=24) (never executed)

  • Index Cond: ((b_1.id_contrato)::text = (id)::text)
61. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabusu_emp_modelo mod_1 (cost=0.00..7.43 rows=243 width=23) (never executed)

62. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabusu_emp_modelo_modalidadecobranca mc_1 (cost=0.00..1.03 rows=3 width=22) (never executed)

63. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabusu_emp_modelo_tipocontratacao tc_1 (cost=0.00..1.06 rows=6 width=25) (never executed)

64. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabusu_produto prod_1 (cost=0.00..24.56 rows=456 width=20) (never executed)

65. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabusu_produto_segmentacao cob_1 (cost=0.00..1.16 rows=16 width=17) (never executed)

66. 0.000 0.000 ↓ 0.0 0

Index Scan using tabservico_pk on tabservico s_1 (cost=0.42..5.28 rows=1 width=67) (never executed)

  • Index Cond: ((apc.id_servico)::text = (id)::text)
67. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabctactb cd_1 (cost=0.00..55.19 rows=1,819 width=76) (never executed)

68. 0.000 0.000 ↓ 0.0 0

Seq Scan on tabctactb cc_1 (cost=0.00..55.19 rows=1,819 width=76) (never executed)

Planning time : 20.011 ms
Execution time : 3,225,247.987 ms