SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
Fetch Size

Ganhe desempenho, pergunte-me como
Fetch Size

É a quantidade esperada de resultados. quando informada,
muito o Oracle (e outros bancos!) envia as informações de
forma diferente.

JDBC esconde os detalhes ccomplexos do protocolo de
comunicação com o banco (TNS do oracle, por exemplo), mas
contempla os problemas comuns a todos eles.
Exemplo(by nulaya)

var b1 varchar2(4000);
select /*+ CHOOSE */
    null
   into :b1
from
   dual
where
   1e1 = 1e1
connect by
   rownum <= 1e3;
Exemplo complementado (by nulaya)
set echo off define off scan off feedback off heading off;
set timing on termout on autotrace on;
set pagesize 0 linesize 1024 arraysize 1;
var b1 varchar2(4000);

select /*+ CHOOSE */
   null
   into :b1
from
   dual
where
   1e1 = 1e1
connect by
   rownum <= 1e3;
Resultado

Decorrido: 00:00:04.12
Plano de Execução
----------------------------------------------------------
Plan hash value: 634278704
-------------------------------------------------------------------------------
| Id | Operation                       | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT                             |    | 1 | 2 (0)| 00:00:01 |
| 1 | COUNT                              |     |      |         |        |
|* 2 | FILTER                          |     |      |         |        |
|* 3 | CONNECT BY WITHOUT FILTERING|                               |       |    | |
| 4 | FAST DUAL                            |     | 1 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------------
Resultado (cont.)

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(1e1=1e1)
   3 - filter(ROWNUM<=1e3)
Estatística
----------------------------------------------------------
         0 recursive calls
         0 db block gets
         0 consistent gets
         0 physical reads
         0 redo size
     91309 bytes sent via SQL*Net to client
     11334 bytes received via SQL*Net from client
      1002 SQL*Net roundtrips to/from client
         1 sorts (memory)
         0 sorts (disk)
      1000 rows processed
Exemplo complementado 2 (by nulaya)

set echo off define off scan off feedback off heading off;
set timing on termout on autotrace on;
set pagesize 0 linesize 1024 arraysize 1000;
var b1 varchar2(4000);

select /*+ CHOOSE */
   null
   into :b1
from
   dual
where
   1e1 = 1e1
connect by
   rownum <= 1e3;
Resultado 2

Decorrido: 00:00:03.81
Plano de Execução
----------------------------------------------------------
Plan hash value: 634278704
-------------------------------------------------------------------------------
| Id | Operation                       | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT                             |    | 1 | 2 (0)| 00:00:01 |
| 1 | COUNT                              |     |      |         |        |
|* 2 | FILTER                          |     |      |         |        |
|* 3 | CONNECT BY WITHOUT FILTERING|                               |       |    | |
| 4 | FAST DUAL                            |     | 1 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------------
Resultado 2 (cont.)

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(1e1=1e1)
   3 - filter(ROWNUM<=1e3)
Estatística
----------------------------------------------------------
         0 recursive calls
         0 db block gets
         0 consistent gets
         0 physical reads
         0 redo size
      5393 bytes sent via SQL*Net to client
       345 bytes received via SQL*Net from client
         3 SQL*Net roundtrips to/from client
         1 sorts (memory)
         0 sorts (disk)
      1000 rows processed
Roundtrip e Payload
(...)                                                (...)
91309 bytes sent via SQL*Net to client               5393 bytes sent via SQL*Net to client
      11334 bytes received via SQL*Net from client         345 bytes received via SQL*Net from client
      1002 SQL*Net roundtrips to/from client                3 SQL*Net roundtrips to/from client
(...)                                                (...)


 The round-trip delay time (RTD) or round-trip time (RTT) is the length of time it
 takes for a signal to be sent plus the length of time it takes for an acknowledgment
 of that signal to be received. (wikipedia)

    Payload ou carga. Refere-se à quantidade de dados
 sendo trafegada.
    Um payload baixo implica em mais pacotes para
 transportar uma mesma quantidade de dados, implicando
 em mais roundtrip.
    É como transportar 100 litros de água em um balde
 de 10 litros, mas carregar apenas 1 litro por vez.
Use o "fetch size" adequado!

   Com JDBC é possível informar quantos resultados são
esperados. Não informar quantos resultados são esperados
faz o JDBC utilizar o padrão de 1 resultado.
   Se vamos alimentar uma grid com tamaanho de exibição
padrão de 10 linhas:

  (...)
 PreparedStatement pst = con.prepareStatement(sql);
 pst.setParameter(1,vo.getNome());
 pst.setFetchSize(10);// @since 1.2
 ResultSet rs = pst.executeQuery();
 (...)
JPA/Hibernate tem também, :)

<property name="hibernate.jdbc.fetch_size">20</property>

ou

<property name="eclipselink.jdbc.fetch-size" value="20"/>
?
FIM
Miniseminario fetch size
Miniseminario fetch size

Contenu connexe

Similaire à Miniseminario fetch size

As percepções Relativas na Application Performance Management, por Gilberto M...
As percepções Relativas na Application Performance Management, por Gilberto M...As percepções Relativas na Application Performance Management, por Gilberto M...
As percepções Relativas na Application Performance Management, por Gilberto M...
Joao Galdino Mello de Souza
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
2m Assessoria
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
2m Assessoria
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
2m Assessoria
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
2m Assessoria
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
2m Assessoria
 
VoltDB talk at QCON-Brasil
VoltDB talk at QCON-BrasilVoltDB talk at QCON-Brasil
VoltDB talk at QCON-Brasil
Edward Ribeiro
 
Virtualização de Banco de Dados por Bruno Domingues
Virtualização de Banco de Dados por Bruno DominguesVirtualização de Banco de Dados por Bruno Domingues
Virtualização de Banco de Dados por Bruno Domingues
Joao Galdino Mello de Souza
 
Calculos instalacoes eletricas
Calculos instalacoes eletricasCalculos instalacoes eletricas
Calculos instalacoes eletricas
Ca Bezerra
 
(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...
(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...
(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...
daimonkonicz823
 

Similaire à Miniseminario fetch size (20)

Uso de estatísticas pelo postgre sql
Uso de estatísticas pelo postgre sqlUso de estatísticas pelo postgre sql
Uso de estatísticas pelo postgre sql
 
Comunidades Virtuais
Comunidades VirtuaisComunidades Virtuais
Comunidades Virtuais
 
Exercicios 06
Exercicios 06Exercicios 06
Exercicios 06
 
Controle Digital de Velocidade de um Motor CC usando Matlab®
Controle Digital de Velocidade de um Motor CC usando Matlab®Controle Digital de Velocidade de um Motor CC usando Matlab®
Controle Digital de Velocidade de um Motor CC usando Matlab®
 
As percepções Relativas na Application Performance Management, por Gilberto M...
As percepções Relativas na Application Performance Management, por Gilberto M...As percepções Relativas na Application Performance Management, por Gilberto M...
As percepções Relativas na Application Performance Management, por Gilberto M...
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
 
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docxMAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 512024.docx
 
(10) network
(10) network(10) network
(10) network
 
VoltDB talk at QCON-Brasil
VoltDB talk at QCON-BrasilVoltDB talk at QCON-Brasil
VoltDB talk at QCON-Brasil
 
Pvn bаsico
Pvn bаsicoPvn bаsico
Pvn bаsico
 
Curso CAT3D 2015 - Resumo das noviades entre 2014 e 2015
Curso CAT3D 2015 - Resumo das noviades entre 2014 e 2015Curso CAT3D 2015 - Resumo das noviades entre 2014 e 2015
Curso CAT3D 2015 - Resumo das noviades entre 2014 e 2015
 
Virtualização de Banco de Dados por Bruno Domingues
Virtualização de Banco de Dados por Bruno DominguesVirtualização de Banco de Dados por Bruno Domingues
Virtualização de Banco de Dados por Bruno Domingues
 
Infraestrutura do Centro de Dados - Inducao_simplificado.pptx
Infraestrutura do Centro de Dados - Inducao_simplificado.pptxInfraestrutura do Centro de Dados - Inducao_simplificado.pptx
Infraestrutura do Centro de Dados - Inducao_simplificado.pptx
 
(2013-05-03) AudioLazy - Slides
(2013-05-03) AudioLazy - Slides(2013-05-03) AudioLazy - Slides
(2013-05-03) AudioLazy - Slides
 
Descricao de-laboratorios
Descricao de-laboratoriosDescricao de-laboratorios
Descricao de-laboratorios
 
Calculos instalacoes eletricas
Calculos instalacoes eletricasCalculos instalacoes eletricas
Calculos instalacoes eletricas
 
(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...
(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...
(43)99668 6495 ASSESSORIA MAPA - MICROPROCESSADORES E MICROCONTROLADORES - 51...
 

Dernier

Dernier (6)

ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docxATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
 
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docxATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
 
Boas práticas de programação com Object Calisthenics
Boas práticas de programação com Object CalisthenicsBoas práticas de programação com Object Calisthenics
Boas práticas de programação com Object Calisthenics
 
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docxATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
 
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docxATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
 
Padrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemploPadrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemplo
 

Miniseminario fetch size

  • 1. Fetch Size Ganhe desempenho, pergunte-me como
  • 2. Fetch Size É a quantidade esperada de resultados. quando informada, muito o Oracle (e outros bancos!) envia as informações de forma diferente. JDBC esconde os detalhes ccomplexos do protocolo de comunicação com o banco (TNS do oracle, por exemplo), mas contempla os problemas comuns a todos eles.
  • 3. Exemplo(by nulaya) var b1 varchar2(4000); select /*+ CHOOSE */ null into :b1 from dual where 1e1 = 1e1 connect by rownum <= 1e3;
  • 4. Exemplo complementado (by nulaya) set echo off define off scan off feedback off heading off; set timing on termout on autotrace on; set pagesize 0 linesize 1024 arraysize 1; var b1 varchar2(4000); select /*+ CHOOSE */ null into :b1 from dual where 1e1 = 1e1 connect by rownum <= 1e3;
  • 5. Resultado Decorrido: 00:00:04.12 Plano de Execução ---------------------------------------------------------- Plan hash value: 634278704 ------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Cost (%CPU)| Time | ------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 | | 1 | COUNT | | | | | |* 2 | FILTER | | | | | |* 3 | CONNECT BY WITHOUT FILTERING| | | | | | 4 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | -------------------------------------------------------------------------------
  • 6. Resultado (cont.) Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter(1e1=1e1) 3 - filter(ROWNUM<=1e3) Estatística ---------------------------------------------------------- 0 recursive calls 0 db block gets 0 consistent gets 0 physical reads 0 redo size 91309 bytes sent via SQL*Net to client 11334 bytes received via SQL*Net from client 1002 SQL*Net roundtrips to/from client 1 sorts (memory) 0 sorts (disk) 1000 rows processed
  • 7. Exemplo complementado 2 (by nulaya) set echo off define off scan off feedback off heading off; set timing on termout on autotrace on; set pagesize 0 linesize 1024 arraysize 1000; var b1 varchar2(4000); select /*+ CHOOSE */ null into :b1 from dual where 1e1 = 1e1 connect by rownum <= 1e3;
  • 8. Resultado 2 Decorrido: 00:00:03.81 Plano de Execução ---------------------------------------------------------- Plan hash value: 634278704 ------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Cost (%CPU)| Time | ------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 | | 1 | COUNT | | | | | |* 2 | FILTER | | | | | |* 3 | CONNECT BY WITHOUT FILTERING| | | | | | 4 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | -------------------------------------------------------------------------------
  • 9. Resultado 2 (cont.) Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter(1e1=1e1) 3 - filter(ROWNUM<=1e3) Estatística ---------------------------------------------------------- 0 recursive calls 0 db block gets 0 consistent gets 0 physical reads 0 redo size 5393 bytes sent via SQL*Net to client 345 bytes received via SQL*Net from client 3 SQL*Net roundtrips to/from client 1 sorts (memory) 0 sorts (disk) 1000 rows processed
  • 10. Roundtrip e Payload (...) (...) 91309 bytes sent via SQL*Net to client 5393 bytes sent via SQL*Net to client 11334 bytes received via SQL*Net from client 345 bytes received via SQL*Net from client 1002 SQL*Net roundtrips to/from client 3 SQL*Net roundtrips to/from client (...) (...) The round-trip delay time (RTD) or round-trip time (RTT) is the length of time it takes for a signal to be sent plus the length of time it takes for an acknowledgment of that signal to be received. (wikipedia) Payload ou carga. Refere-se à quantidade de dados sendo trafegada. Um payload baixo implica em mais pacotes para transportar uma mesma quantidade de dados, implicando em mais roundtrip. É como transportar 100 litros de água em um balde de 10 litros, mas carregar apenas 1 litro por vez.
  • 11. Use o "fetch size" adequado! Com JDBC é possível informar quantos resultados são esperados. Não informar quantos resultados são esperados faz o JDBC utilizar o padrão de 1 resultado. Se vamos alimentar uma grid com tamaanho de exibição padrão de 10 linhas: (...) PreparedStatement pst = con.prepareStatement(sql); pst.setParameter(1,vo.getNome()); pst.setFetchSize(10);// @since 1.2 ResultSet rs = pst.executeQuery(); (...)
  • 12. JPA/Hibernate tem também, :) <property name="hibernate.jdbc.fetch_size">20</property> ou <property name="eclipselink.jdbc.fetch-size" value="20"/>
  • 13. ?
  • 14. FIM