RES: RES: RES: [oracle_br] PLANO DE EXECUÇÃO
Chiappa, Também já desconfiava, já tinha executado o join normal e também mostrou acesso à depto. Obrigado pela confirmação, pensei que estivesse me escapando algo. Um abraço. _ De: jlchiappa [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 22 de novembro de 2005 18:24 Para: oracle_br@yahoogrupos.com.br Assunto: Re: RES: RES: [oracle_br] PLANO DE EXECUÇÃO Quando vc falou que era 8i, já ficava mesmo no ar a suspeita , já que recursos como select executado como "coluna" de outro select foram introduzidos só nos releases finais do 8i, podia ser mesmo que o explain plan do 8i não tivesse sido corretamente atualizado : fiz o teste no 8i e tive o mesmo resultado que vc no Personal 8.1.7.4.1 no windows. E a questão é com as novas sintaxes, um join tradicional mostra normal o acesso à dept. eis meus testes, tá confirmado : [EMAIL PROTECTED]:SQL>set autotrace on [EMAIL PROTECTED]:SQL> [EMAIL PROTECTED]:SQL>select e.empno, e.sal, (select deptno from dept d where 2 d.deptno = e.deptno) num_dep 3 from emp e where sal > 1000; EMPNOSALNUM_DEP -- -- -- 7499 1600 30 7521 1250 30 7566 2975 20 7654 1250 30 7698 2850 30 7782 2450 10 7788 3000 20 7839 5000 10 7844 1500 30 7876 1100 20 7902 3000 20 7934 1300 10 12 linhas selecionadas. Execution Plan -- 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=14 Bytes=112) 10 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) Statistics -- 1018 recursive calls 9 db block gets 187 consistent gets 9 physical reads 0 redo size 1063 bytes sent via SQL*Net to client 425 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 26 sorts (memory) 0 sorts (disk) 12 rows processed [EMAIL PROTECTED]:SQL>select e.empno, e.sal, (select dname from dept d where 2 d.deptno = e.deptno) nome_dep 3 from emp e where sal > 1000; EMPNOSAL NOME_DEP -- -- -- 7499 1600 SALES 7521 1250 SALES 7566 2975 RESEARCH 7654 1250 SALES 7698 2850 SALES 7782 2450 ACCOUNTING 7788 3000 RESEARCH 7839 5000 ACCOUNTING 7844 1500 SALES 7876 1100 RESEARCH 7902 3000 RESEARCH 7934 1300 ACCOUNTING 12 linhas selecionadas. Execution Plan -- 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=14 Bytes=112) 10 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) Statistics -- 0 recursive calls 4 db block gets 7 consistent gets 0 physical reads 0 redo size 1115 bytes sent via SQL*Net to client 425 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 2 sorts (memory) 0 sorts (disk) 12 rows processed [EMAIL PROTECTED]:SQL> [EMAIL PROTECTED]:SQL>select e.empno, e.sal, d.dname 2 from emp e, dept d 3 where sal > 1000 and d.deptno = e.deptno; EMPNOSAL DNAME -- -- -- 7499 1600 SALES 7521 1250 SALES 7566 2975 RESEARCH 7654 1250 SALES 7698 2850 SALES 7782 2450 ACCOUNTING 7788 3000 RESEARCH 7839 5000 ACCOUNTING 7844 1500 SALES 7876 1100 RESEARCH 7902 3000 RESEARCH 7934 1300 ACCOUNTING 12 linhas selecionadas. Execution Plan -- 0 SE
Re: RES: RES: [oracle_br] PLANO DE EXECUÇÃO
Quando vc falou que era 8i, já ficava mesmo no ar a suspeita , já que recursos como select executado como "coluna" de outro select foram introduzidos só nos releases finais do 8i, podia ser mesmo que o explain plan do 8i não tivesse sido corretamente atualizado : fiz o teste no 8i e tive o mesmo resultado que vc no Personal 8.1.7.4.1 no windows. E a questão é com as novas sintaxes, um join tradicional mostra normal o acesso à dept. eis meus testes, tá confirmado : [EMAIL PROTECTED]:SQL>set autotrace on [EMAIL PROTECTED]:SQL> [EMAIL PROTECTED]:SQL>select e.empno, e.sal, (select deptno from dept d where 2 d.deptno = e.deptno) num_dep 3 from emp e where sal > 1000; EMPNOSALNUM_DEP -- -- -- 7499 1600 30 7521 1250 30 7566 2975 20 7654 1250 30 7698 2850 30 7782 2450 10 7788 3000 20 7839 5000 10 7844 1500 30 7876 1100 20 7902 3000 20 7934 1300 10 12 linhas selecionadas. Execution Plan -- 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=14 Bytes=112) 10 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) Statistics -- 1018 recursive calls 9 db block gets 187 consistent gets 9 physical reads 0 redo size 1063 bytes sent via SQL*Net to client 425 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 26 sorts (memory) 0 sorts (disk) 12 rows processed [EMAIL PROTECTED]:SQL>select e.empno, e.sal, (select dname from dept d where 2 d.deptno = e.deptno) nome_dep 3 from emp e where sal > 1000; EMPNOSAL NOME_DEP -- -- -- 7499 1600 SALES 7521 1250 SALES 7566 2975 RESEARCH 7654 1250 SALES 7698 2850 SALES 7782 2450 ACCOUNTING 7788 3000 RESEARCH 7839 5000 ACCOUNTING 7844 1500 SALES 7876 1100 RESEARCH 7902 3000 RESEARCH 7934 1300 ACCOUNTING 12 linhas selecionadas. Execution Plan -- 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=14 Bytes=112) 10 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) Statistics -- 0 recursive calls 4 db block gets 7 consistent gets 0 physical reads 0 redo size 1115 bytes sent via SQL*Net to client 425 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 2 sorts (memory) 0 sorts (disk) 12 rows processed [EMAIL PROTECTED]:SQL> [EMAIL PROTECTED]:SQL>select e.empno, e.sal, d.dname 2 from emp e, dept d 3 where sal > 1000 and d.deptno = e.deptno; EMPNOSAL DNAME -- -- -- 7499 1600 SALES 7521 1250 SALES 7566 2975 RESEARCH 7654 1250 SALES 7698 2850 SALES 7782 2450 ACCOUNTING 7788 3000 RESEARCH 7839 5000 ACCOUNTING 7844 1500 SALES 7876 1100 RESEARCH 7902 3000 RESEARCH 7934 1300 ACCOUNTING 12 linhas selecionadas. Execution Plan -- 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=14 Bytes=266) 10 HASH JOIN (Cost=3 Card=14 Bytes=266) 21 TABLE ACCESS (FULL) OF 'DEPT' (Cost=1 Card=4 Bytes=44) 31 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) Statistics -- 0 recursive calls 8 db block gets 3 consistent gets 0 physical reads 0 r
RES: RES: RES: [oracle_br] PLANO DE EXECUÇÃO
olha ai Márcio Parece que deu igual ?? select e.empno, e.sal, (select dname from dept d where d.deptno = e.deptno) nome_dep from emp e where sal > 1000 call count cpuelapsed disk querycurrent rows --- -- -- -- -- -- -- Parse1 0.02 0.02 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch2 0.00 0.00 0 7 4 12 --- -- -- -- -- -- -- total4 0.02 0.02 0 7 4 12 Misses in library cache during parse: 0 Optimizer goal: FIRST_ROWS Parsing user id: 94 Rows Row Source Operation --- --- 12 TABLE ACCESS FULL EMP select e.empno, e.sal, (select deptno from dept d where d.deptno = e.deptno) num_dep from emp e where sal > 1000 call count cpuelapsed disk querycurrent rows --- -- -- -- -- -- -- Parse1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch2 0.00 0.00 0 4 4 12 --- -- -- -- -- -- -- total4 0.00 0.00 0 4 4 12 Misses in library cache during parse: 0 Optimizer goal: FIRST_ROWS Parsing user id: 94 Rows Row Source Operation --- --- 12 TABLE ACCESS FULL EMP _ De: Marcio Portes [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 22 de novembro de 2005 11:13 Para: oracle_br@yahoogrupos.com.br Assunto: Re: RES: RES: [oracle_br] PLANO DE EXECUÇÃO Poderia rodar os exemplos com o tkprof e colocar o resultado na lista? --- Em oracle_br@yahoogrupos.com.br, Alexandre Eduardo Borges <[EMAIL PROTECTED]> escreveu > Caro chiappa > > Essa é exatamente a minha dúvida, como ele trouxe a descrição sem > acessar a tabela , sendo que só existe índice no código. Rodei o seu exemplo > aqui, nossa versão é 8.1.7.4 , olha aí o resultado , será que é pau dessa > versão?? > > SQL> select * from V$version; > > BANNER > --- > Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production > PL/SQL Release 8.1.7.4.0 - Production > CORE8.1.7.2.1 Production > TNS for 32-bit Windows: Version 8.1.7.4.0 - Production > NLSRTL Version 3.4.1.0.0 - Production > > > SQL> set autotrace on > SQL> select e.empno, e.sal, (select deptno from dept d where > 2 d.deptno = e.deptno) num_dep > 3 from emp e where sal > 1000; > > EMPNOSALNUM_DEP > -- -- -- > 7499 1600 30 > 7521 1250 30 > 7566 2975 20 > 7654 1250 30 > 7698 2850 30 > 7782 2450 10 > 7788 3000 20 > 7839 5000 10 > 7844 1500 30 > 7876 1100 20 > 7902 3000 20 > > EMPNOSALNUM_DEP > -- -- -- > 7934 1300 10 > > 12 linhas selecionadas. > > > Execution Plan > -- >0 SELECT STATEMENT Optimizer=FIRST_ROWS (Cost=1 Card=14 Bytes= > 112) > >10 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) > > > > > 2º teste= > > > SQL> select e.empno, e.sal, (select dname from dept d where > 2 d.deptno = e.deptno) nome_dep > 3 from emp e where sal > 1000; > > EMPNOSAL NOME_DEP > -- -- -- > 7499 1600 SALES > 7521 1250 SALES > 7566 2975 RESEARCH > 7654 1250 SALES > 7698 2850 SALES > 7782 2450 ACCOUNTING > 7788 3000 RESEARCH > 7839 5000 ACCOUNTING > 7844 1500 SALES > 7876 1100 RESEARCH > 7902 3000 RESEARCH > > EMPNOSAL NOME_DEP > -- -- -- > 7934 1300 ACCOUNTING > > 12 linha
Re: RES: RES: [oracle_br] PLANO DE EXECUÇÃO
Poderia rodar os exemplos com o tkprof e colocar o resultado na lista? --- Em oracle_br@yahoogrupos.com.br, Alexandre Eduardo Borges <[EMAIL PROTECTED]> escreveu > Caro chiappa > > Essa é exatamente a minha dúvida, como ele trouxe a descrição sem > acessar a tabela , sendo que só existe índice no código. Rodei o seu exemplo > aqui, nossa versão é 8.1.7.4 , olha aí o resultado , será que é pau dessa > versão?? > > SQL> select * from V$version; > > BANNER > --- > Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production > PL/SQL Release 8.1.7.4.0 - Production > CORE8.1.7.2.1 Production > TNS for 32-bit Windows: Version 8.1.7.4.0 - Production > NLSRTL Version 3.4.1.0.0 - Production > > > SQL> set autotrace on > SQL> select e.empno, e.sal, (select deptno from dept d where > 2 d.deptno = e.deptno) num_dep > 3 from emp e where sal > 1000; > > EMPNOSALNUM_DEP > -- -- -- > 7499 1600 30 > 7521 1250 30 > 7566 2975 20 > 7654 1250 30 > 7698 2850 30 > 7782 2450 10 > 7788 3000 20 > 7839 5000 10 > 7844 1500 30 > 7876 1100 20 > 7902 3000 20 > > EMPNOSALNUM_DEP > -- -- -- > 7934 1300 10 > > 12 linhas selecionadas. > > > Execution Plan > -- >0 SELECT STATEMENT Optimizer=FIRST_ROWS (Cost=1 Card=14 Bytes= > 112) > >10 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) > > > > > 2º teste= > > > SQL> select e.empno, e.sal, (select dname from dept d where > 2 d.deptno = e.deptno) nome_dep > 3 from emp e where sal > 1000; > > EMPNOSAL NOME_DEP > -- -- -- > 7499 1600 SALES > 7521 1250 SALES > 7566 2975 RESEARCH > 7654 1250 SALES > 7698 2850 SALES > 7782 2450 ACCOUNTING > 7788 3000 RESEARCH > 7839 5000 ACCOUNTING > 7844 1500 SALES > 7876 1100 RESEARCH > 7902 3000 RESEARCH > > EMPNOSAL NOME_DEP > -- -- -- > 7934 1300 ACCOUNTING > > 12 linhas selecionadas. > > > Execution Plan > -- >0 SELECT STATEMENT Optimizer=FIRST_ROWS (Cost=1 Card=14 Bytes= > 112) > >10 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112) > > > > > Viu a diferença ?/ > > Como trouxe o nome do departamento acessando somente a tabela EMP?? > > > Obrigado... > > > _ > > De: jlchiappa [mailto:[EMAIL PROTECTED] > Enviada em: terça-feira, 22 de novembro de 2005 10:26 > Para: oracle_br@yahoogrupos.com.br > Assunto: Re: RES: [oracle_br] PLANO DE EXECUÇÃO > > > Ao que eu entendi, o campo descrição ** não tem ** índice nele, então > deveria sim ter sido feito um acesso ao índice, ** E ** também um > acesso à tabela, exemplo : > > [EMAIL PROTECTED]:SQL>select * from V$version; > > BANNER > > Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production > PL/SQL Release 9.2.0.5.0 - Production > CORE9.2.0.6.0 Production > TNS for HPUX: Version 9.2.0.5.0 - Production > NLSRTL Version 9.2.0.5.0 - Production > > [EMAIL PROTECTED]:SQL>set autotrace on > > ==> primeiro exemplo, select secundário trazendo um campo indexado > apenas) : > > [EMAIL PROTECTED]:SQL>select e.empno, e.sal, (select deptno from dept d where > d.deptno = e.deptno) num_dep > 2 from emp e where sal > 1000; > > EMPNOSALNUM_DEP > -- -- -- > 7499 1600 30 > 7521 1250 30 > 7566 2975 20 > 7654 1250 30 > 7698 2850 30 > 7782 2450 10 > 7788 3000 20 > 7839 5000 10 > 7844 1500 30 > 7876 1100 20 > 7902 3000 20 > 7934 1300 10 > > 12 linhas selecionadas. > > > Execution Plan > -- >0 SE