{"id":1743,"date":"2018-08-09T10:18:18","date_gmt":"2018-08-09T13:18:18","guid":{"rendered":"http:\/\/dbtimewizard.com.br\/blog\/?p=1743"},"modified":"2019-11-11T18:43:49","modified_gmt":"2019-11-11T21:43:49","slug":"histogramas-quando-devemos-evita-los","status":"publish","type":"post","link":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/","title":{"rendered":"Histogramas: Quando devemos evit\u00e1-los?"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">O uso de <strong><a href=\"http:\/\/dbtimewizard.com.br\/blog\/histogramas-qual-importancia-deles\/\" target=\"_blank\">histogramas<\/a><\/strong> ajuda o Otimizador a ser mais preciso no c\u00e1lculo da cardinalidade das opera\u00e7\u00f5es no plano de execu\u00e7\u00e3o, mas existem situa\u00e7\u00f5es em que n\u00e3o devemos utiliz\u00e1-los, pois eles v\u00e3o induzir o Otimizador a criar planos de execu\u00e7\u00e3o de baixa qualidade. Neste artigo vamos mostrar uma destas situa\u00e7\u00f5es onde o Otimizador realiza um c\u00e1lculo de cardinalidade muito ruim, devido a exist\u00eancia do histograma em uma coluna da tabela e como consequ\u00eancia ele vai gerar um plano de execu\u00e7\u00e3o de baixo desempenho.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">Para demonstrar esta situa\u00e7\u00e3o, vamos realizar uma simula\u00e7\u00e3o pr\u00e1tica com as seguintes etapas:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">1) Criar uma tabela com um \u00edndice e coletar as estat\u00edsticas<\/span><br \/>\n<span style=\"font-size: 12pt;\">2) Executar uma consulta na tabela criada e verificar o plano de execu\u00e7\u00e3o<\/span><br \/>\n<span style=\"font-size: 12pt;\">3) Eliminar o histograma da coluna inclu\u00edda na cl\u00e1usula WHERE da consulta<\/span><br \/>\n<span style=\"font-size: 12pt;\">4) Executar a mesma consulta novamente e verificar o plano de execu\u00e7\u00e3o<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2 style=\"text-align: justify;\"><span style=\"font-size: 14pt;\">1) Criar a tabela, \u00edndice e estat\u00edsticas<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">Vamos criar os objetos necess\u00e1rios para realizar a nossa simula\u00e7\u00e3o.<\/span><br \/>\n&nbsp;<\/p>\n<div class=\"codecolorer-container php default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;width:100%;height:520px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/>64<br \/>65<br \/>66<br \/>67<br \/>68<br \/>69<br \/>70<br \/>71<br \/>72<br \/>73<br \/>74<br \/>75<br \/>76<br \/>77<br \/>78<br \/>79<br \/><\/div><\/td><td><div class=\"php codecolorer\">SQL <span class=\"sy0\">&gt;<\/span> SELECT <span class=\"sy0\">*<\/span> FROM V<span class=\"re0\">$VERSION<\/span> where rownum <span class=\"sy0\">&lt;<\/span> <span class=\"nu0\">2<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nBANNER<br \/>\n<span class=\"sy0\">--------------------------------------------------------------------------------<\/span><br \/>\nOracle Database 11g Enterprise Edition Release 11<span class=\"sy0\">.<\/span>2<span class=\"sy0\">.<\/span>0<span class=\"sy0\">.<\/span>4<span class=\"sy0\">.<\/span>0 <span class=\"sy0\">-<\/span> 64bit Production<br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> create table dbtw054 <span class=\"kw1\">as<\/span> select <span class=\"sy0\">*<\/span> from dba_objects where rownum <span class=\"sy0\">&lt;<\/span> <span class=\"nu0\">1<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nTabela criada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> ALTER TABLE dbtw054 MODIFY <span class=\"br0\">&#40;<\/span>object_type varchar2<span class=\"br0\">&#40;<\/span><span class=\"nu0\">60<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nTabela alterada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> insert into dbtw054 &nbsp; select<br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OWNER<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">3<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OBJECT_NAME<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">4<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SUBOBJECT_NAME<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">5<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OBJECT_ID<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">6<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DATA_OBJECT_ID<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">7<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'x123456789y123456789z123456789w123'<\/span><span class=\"sy0\">||<\/span>OBJECT_TYPE<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">8<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CREATED<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">9<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LAST_DDL_TIME<span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">10<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TIMESTAMP<span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">11<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;STATUS<span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">12<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TEMPORARY<span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">13<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GENERATED<span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">14<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SECONDARY<span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">15<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"kw2\">NAMESPACE<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">16<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EDITION_NAME<br \/>\n&nbsp;<span class=\"nu0\">17<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from dba_objects<br \/>\n&nbsp;<span class=\"nu0\">18<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;where object_type in <span class=\"br0\">&#40;<\/span><span class=\"st_h\">'QUEUE'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">19<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'TABLE SUBPARTITION'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">20<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'RULE SET'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">21<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'CONSUMER GROUP'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">22<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'MATERIALIZED VIEW'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">23<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'PROGRAM'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">24<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'DATABASE LINK'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">25<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'JOB CLASS'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">26<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'EVALUATION CONTEXT'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">27<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'UNDEFINED'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">28<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'RESOURCE PLAN'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">29<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'CLUSTER'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">30<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'JAVA SOURCE'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">31<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'WINDOW'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">32<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'INDEXTYPE'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">33<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'RULE'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">34<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'CONTEXT'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">35<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'DIMENSION'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">36<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'SCHEDULER GROUP'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">37<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'SCHEDULE'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">38<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'DESTINATION'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">39<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'EDITION'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">40<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'REWRITE EQUIVALENCE'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<span class=\"nu0\">41<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st_h\">'LOB PARTITION'<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"nu0\">362<\/span> linhas criadas<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> commit<span class=\"sy0\">;<\/span><br \/>\n<br \/>\nCommit conclu\u00ed<span class=\"kw1\">do<\/span><span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> <a href=\"http:\/\/www.php.net\/exec\"><span class=\"kw3\">exec<\/span><\/a> dbms_stats<span class=\"sy0\">.<\/span>gather_table_stats<span class=\"br0\">&#40;<\/span>ownname<span class=\"sy0\">=&gt;<\/span> USER<span class=\"sy0\">,<\/span> tabname<span class=\"sy0\">=&gt;<\/span> <span class=\"st_h\">'DBTW054'<\/span><span class=\"sy0\">,<\/span> method_opt<span class=\"sy0\">=&gt;<\/span><span class=\"st_h\">'FOR ALL COLUMNS SIZE SKEWONLY'<\/span><span class=\"sy0\">,<\/span>cascade<span class=\"sy0\">=&gt;<\/span><span class=\"kw4\">true<\/span><span class=\"sy0\">,<\/span>force<span class=\"sy0\">=&gt;<\/span><span class=\"kw4\">true<\/span><span class=\"sy0\">,<\/span>degree<span class=\"sy0\">=&gt;<\/span><span class=\"nu0\">16<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nProcedimento PL<span class=\"sy0\">\/<\/span>SQL conclu\u00ed<span class=\"kw1\">do<\/span> com sucesso<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> create index dbtw054_IDX on dbtw054<span class=\"br0\">&#40;<\/span>object_type<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n\u00cdndice criado<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 14pt;\">2) Executar uma consulta usando a tabela criada<\/span><\/h2>\n<p>&nbsp;<\/p>\n<div class=\"codecolorer-container php default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;width:100%;height:520px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/>64<br \/>65<br \/>66<br \/>67<br \/>68<br \/>69<br \/>70<br \/>71<br \/>72<br \/>73<br \/>74<br \/>75<br \/>76<br \/>77<br \/>78<br \/>79<br \/>80<br \/>81<br \/>82<br \/>83<br \/>84<br \/>85<br \/>86<br \/>87<br \/>88<br \/>89<br \/>90<br \/><\/div><\/td><td><div class=\"php codecolorer\">SQL <span class=\"sy0\">&gt;<\/span> ALTER SESSION SET statistics_level <span class=\"sy0\">=<\/span> ALL<span class=\"sy0\">;<\/span><br \/>\n<br \/>\nSess\u00e3o alterada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT <span class=\"coMULTI\">\/* DBTW-054.1 *\/<\/span> object_name<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp; &nbsp; &nbsp; owner<br \/>\n&nbsp; <span class=\"nu0\">3<\/span> &nbsp; &nbsp;FROM DBTW054<br \/>\n&nbsp; <span class=\"nu0\">4<\/span> &nbsp; WHERE object_type<span class=\"sy0\">=<\/span><span class=\"st_h\">'x123456789y123456789z123456789w123RULE'<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nOBJECT_NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OWNER<br \/>\n<span class=\"sy0\">------------------------------<\/span> <span class=\"sy0\">-------------------<\/span><br \/>\nSYS<span class=\"re0\">$SERVICE_METRICS<\/span>$<span class=\"nu19\">61<\/span> &nbsp; &nbsp; &nbsp; &nbsp; SYS<br \/>\nALERT_QUE$<span class=\"nu19\">1<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SYS<br \/>\nSCHEDULER<span class=\"re0\">$_EVENT_QUEUE<\/span>$<span class=\"nu19\">1<\/span> &nbsp; &nbsp; &nbsp; SYS<br \/>\nSCHEDULER<span class=\"re0\">$_EVENT_QUEUE<\/span>$<span class=\"nu19\">3<\/span> &nbsp; &nbsp; &nbsp; SYS<br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">--<\/span> Recupera o SQL_ID e o CHILD_NUMBER &nbsp;da consulta executada<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> column sql_id new_value m_sql_id<br \/>\nSQL <span class=\"sy0\">&gt;<\/span> column child_number new_value m_child_no<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT sql_id<span class=\"sy0\">,<\/span> child_number<br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp;FROM v<span class=\"re0\">$sql<\/span><br \/>\n&nbsp; <span class=\"nu0\">3<\/span> &nbsp; WHERE sql_text LIKE <span class=\"st_h\">'%DBTW-054.1%'<\/span><br \/>\n&nbsp; <span class=\"nu0\">4<\/span> &nbsp; &nbsp; AND sql_text NOT LIKE <span class=\"st_h\">'%v$sql%'<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nSQL_ID &nbsp; &nbsp; &nbsp; &nbsp;CHILD_NUMBER<br \/>\n<span class=\"sy0\">-------------<\/span> <span class=\"sy0\">------------<\/span><br \/>\n3h619x7nhkxq9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">0<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">--<\/span> Gera o relatorio <span class=\"kw1\">do<\/span> plano de execucao da consulta<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT <span class=\"sy0\">*<\/span> FROM TABLE <span class=\"br0\">&#40;<\/span>dbms_xplan<span class=\"sy0\">.<\/span>display_cursor <span class=\"br0\">&#40;<\/span><span class=\"st_h\">'&amp;m_sql_id'<\/span><span class=\"sy0\">,&amp;<\/span>m_child_no<span class=\"sy0\">,<\/span><span class=\"st_h\">'typical iostats last'<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nPLAN_TABLE_OUTPUT<br \/>\n<span class=\"sy0\">----------------------------------------------------------------------------------------------------------------------------------------------------<\/span><br \/>\nSQL_ID &nbsp;3h619x7nhkxq9<span class=\"sy0\">,<\/span> child number <span class=\"nu0\">0<\/span><br \/>\n<span class=\"sy0\">-------------------------------------<\/span><br \/>\nSELECT <span class=\"coMULTI\">\/* DBTW-054.1 *\/<\/span> object_name<span class=\"sy0\">,<\/span> &nbsp; &nbsp; &nbsp; &nbsp;owner &nbsp; FROM DBTW054 &nbsp;WHERE<br \/>\nobject_type<span class=\"sy0\">=:<\/span><span class=\"st0\">&quot;SYS_B_0&quot;<\/span><br \/>\n<br \/>\nPlan <a href=\"http:\/\/www.php.net\/hash\"><span class=\"kw3\">hash<\/span><\/a> value<span class=\"sy0\">:<\/span> <span class=\"nu0\">1846229803<\/span><br \/>\n<br \/>\n<span class=\"sy0\">-----------------------------------------------------------------------------------------------------------------------<\/span><br \/>\n<span class=\"sy0\">|<\/span> Id &nbsp;<span class=\"sy0\">|<\/span> Operation &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">|<\/span> Name &nbsp; &nbsp;<span class=\"sy0\">|<\/span> Starts <span class=\"sy0\">|<\/span> E<span class=\"sy0\">-<\/span>Rows <span class=\"sy0\">|<\/span>E<span class=\"sy0\">-<\/span>Bytes<span class=\"sy0\">|<\/span> Cost <span class=\"br0\">&#40;<\/span><span class=\"sy0\">%<\/span>CPU<span class=\"br0\">&#41;<\/span><span class=\"sy0\">|<\/span> E<span class=\"sy0\">-<\/span><a href=\"http:\/\/www.php.net\/time\"><span class=\"kw3\">Time<\/span><\/a> &nbsp; <span class=\"sy0\">|<\/span> A<span class=\"sy0\">-<\/span>Rows <span class=\"sy0\">|<\/span> &nbsp; A<span class=\"sy0\">-<\/span><a href=\"http:\/\/www.php.net\/time\"><span class=\"kw3\">Time<\/span><\/a> &nbsp; <span class=\"sy0\">|<\/span> Buffers <span class=\"sy0\">|<\/span><br \/>\n<span class=\"sy0\">-----------------------------------------------------------------------------------------------------------------------<\/span><br \/>\n<span class=\"sy0\">|<\/span> &nbsp; <span class=\"nu0\">0<\/span> <span class=\"sy0\">|<\/span> SELECT STATEMENT &nbsp;<span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">1<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; <span class=\"sy0\">|<\/span> &nbsp; &nbsp; <span class=\"nu0\">5<\/span> <span class=\"br0\">&#40;<\/span><span class=\"nu0\">100<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">4<\/span> <span class=\"sy0\">|<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu19\">00.01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">16<\/span> <span class=\"sy0\">|<\/span><br \/>\n<span class=\"sy0\">|*<\/span> &nbsp;<span class=\"nu0\">1<\/span> <span class=\"sy0\">|<\/span> &nbsp;TABLE ACCESS FULL<span class=\"sy0\">|<\/span> DBTW054 <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">1<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp;<span class=\"nu0\">362<\/span> <span class=\"sy0\">|<\/span> <span class=\"nu0\">26788<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; <span class=\"nu0\">5<\/span> &nbsp; <span class=\"br0\">&#40;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">|<\/span> <span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">4<\/span> <span class=\"sy0\">|<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu19\">00.01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">16<\/span> <span class=\"sy0\">|<\/span><br \/>\n<span class=\"sy0\">-----------------------------------------------------------------------------------------------------------------------<\/span><br \/>\n<br \/>\nPredicate Information <span class=\"br0\">&#40;<\/span>identified by operation id<span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><br \/>\n<span class=\"sy0\">---------------------------------------------------<\/span><br \/>\n<br \/>\n&nbsp; &nbsp;<span class=\"nu0\">1<\/span> <span class=\"sy0\">-<\/span> filter<span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;OBJECT_TYPE&quot;<\/span><span class=\"sy0\">=:<\/span>SYS_B_0<span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n<br \/>\n<span class=\"nu0\">19<\/span> linhas selecionadas<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT column_name<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp; &nbsp; &nbsp; num_distinct<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">3<\/span> &nbsp; &nbsp; &nbsp; &nbsp; density<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">4<\/span> &nbsp; &nbsp; &nbsp; &nbsp; num_nulls<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">5<\/span> &nbsp; &nbsp; &nbsp; &nbsp; histogram<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">6<\/span> &nbsp; &nbsp; &nbsp; &nbsp; num_buckets<br \/>\n&nbsp; <span class=\"nu0\">7<\/span> &nbsp; &nbsp;FROM user_tab_col_statistics<br \/>\n&nbsp; <span class=\"nu0\">8<\/span> &nbsp; WHERE table_name <span class=\"sy0\">=<\/span> <span class=\"st_h\">'DBTW054'<\/span><br \/>\n&nbsp; <span class=\"nu0\">9<\/span> &nbsp; &nbsp; AND column_name<span class=\"sy0\">=<\/span><span class=\"st_h\">'OBJECT_TYPE'<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nCOLUMN_NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NUM_DISTINCT &nbsp; &nbsp; &nbsp;DENSITY &nbsp;NUM_NULLS HISTOGRAM &nbsp; &nbsp; &nbsp; NUM_BUCKETS<br \/>\n<span class=\"sy0\">------------------------------<\/span> <span class=\"sy0\">------------<\/span> <span class=\"sy0\">------------<\/span> <span class=\"sy0\">----------<\/span> <span class=\"sy0\">---------------<\/span> <span class=\"sy0\">-----------<\/span><br \/>\nOBJECT_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">22<\/span> &nbsp; <span class=\"nu19\">.001381215<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">0<\/span> FREQUENCY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"nu0\">1<\/span><br \/>\n<br \/>\n<span class=\"nu0\">1<\/span> linha selecionada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT <a href=\"http:\/\/www.php.net\/count\"><span class=\"kw3\">COUNT<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp;FROM dbtw054<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; <a href=\"http:\/\/www.php.net\/count\"><span class=\"kw3\">COUNT<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"sy0\">----------<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">362<\/span><br \/>\n<br \/>\n<span class=\"nu0\">1<\/span> linha selecionada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">Observe no plano de execu\u00e7\u00e3o que o Otimizador estimou que a opera\u00e7\u00e3o TABLE ACCESS FULL selecionaria 362 linhas (E-ROWS) quando na verdade foram selecionada somente 4 linhas (A-ROWS), este erro absurdo ocorreu por que o Otimizador utiliza preferencialmente o histograma, quando ele existe, para fazer o c\u00e1lculo da cardinalidade e quando geramos as estat\u00edsticas no inicio da simula\u00e7\u00e3o utilizando\u00a0o\u00a0pacote DBMS_STATS a cria\u00e7\u00e3o do histograma na coluna OBJECT_TYPE considerou somente os 32 caracteres iniciais desta coluna, desprezando o resto (limite da vers\u00e3o 11g).<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">Consultando a vis\u00e3o de estat\u00edsticas das colunas <strong><span style=\"font-size: 10pt;\">(USER_TAB_COL_STATISTICS)<\/span> <\/strong>verificamos que a coluna OBJECT_TYPE possui um histograma do tipo FREQUENCY com 1 BUCKET, quando deveriam ser 22 BUCKETS pois esta coluna tem 22 valores distintos. Este histograma defeituoso \u00e9 o resultado da combina\u00e7\u00e3o de duas situa\u00e7\u00f5es, os primeiros 32 caracteres dos valores presentes na coluna OBJECT_TYPE serem iguais em todas as linhas da tabela e ao limite de 32 caracteres da vers\u00e3o 11g para a cria\u00e7\u00e3o de histogramas.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">Obs: Na vers\u00e3o 12c este limite \u00e9 de 64 caracteres.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 14pt;\"><strong>3) Eliminar o histograma da coluna OBJECT_TYPE<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">Para ajudar o Otimizador na estimativa da cardinalidade das linhas que ser\u00e3o selecionadas na tabela, podemos eliminar o histograma criado na coluna OBJECT_TYPE e alterar as prefer\u00eancias da coleta de estat\u00edsticas de forma que este histograma n\u00e3o seja mais gerado.<\/span><\/p>\n<p>&nbsp;<\/p>\n<div class=\"codecolorer-container php default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/><\/div><\/td><td><div class=\"php codecolorer\">SQL <span class=\"sy0\">&gt;<\/span> <a href=\"http:\/\/www.php.net\/exec\"><span class=\"kw3\">exec<\/span><\/a> dbms_stats<span class=\"sy0\">.<\/span>delete_column_stats<span class=\"br0\">&#40;<\/span>ownname<span class=\"sy0\">=&gt;<\/span> USER<span class=\"sy0\">,<\/span> tabname<span class=\"sy0\">=&gt;<\/span><span class=\"st_h\">'DBTW054'<\/span><span class=\"sy0\">,<\/span> colname<span class=\"sy0\">=&gt;<\/span><span class=\"st_h\">'OBJECT_TYPE'<\/span><span class=\"sy0\">,<\/span> col_stat_type<span class=\"sy0\">=&gt;<\/span><span class=\"st_h\">'HISTOGRAM'<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nProcedimento PL<span class=\"sy0\">\/<\/span>SQL conclu\u00ed<span class=\"kw1\">do<\/span> com sucesso<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> <a href=\"http:\/\/www.php.net\/exec\"><span class=\"kw3\">exec<\/span><\/a> dbms_stats<span class=\"sy0\">.<\/span>set_table_prefs<span class=\"br0\">&#40;<\/span>USER<span class=\"sy0\">,<\/span> <span class=\"st_h\">'DBTW054'<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'METHOD_OPT'<\/span><span class=\"sy0\">,<\/span> <span class=\"st_h\">'FOR ALL COLUMNS SIZE AUTO, FOR COLUMNS SIZE 1 OBJECT_TYPE'<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nProcedimento PL<span class=\"sy0\">\/<\/span>SQL conclu\u00ed<span class=\"kw1\">do<\/span> com sucesso<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 14pt;\"><strong>4) Executar a mesma consulta novamente<\/strong><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">Vamos executar uma consulta na tabela e verificar a efici\u00eancia do plano de execu\u00e7\u00e3o:<\/span><br \/>\n&nbsp;<\/p>\n<div class=\"codecolorer-container php default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;width:100%;height:520px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/>64<br \/>65<br \/>66<br \/>67<br \/>68<br \/>69<br \/>70<br \/>71<br \/>72<br \/>73<br \/>74<br \/>75<br \/>76<br \/>77<br \/>78<br \/>79<br \/>80<br \/>81<br \/>82<br \/>83<br \/>84<br \/>85<br \/><\/div><\/td><td><div class=\"php codecolorer\">SQL <span class=\"sy0\">&gt;<\/span> ALTER SESSION SET statistics_level <span class=\"sy0\">=<\/span> ALL<span class=\"sy0\">;<\/span><br \/>\n<br \/>\nSess\u00e3o alterada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT <span class=\"coMULTI\">\/* DBTW-054.2 *\/<\/span> object_name<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp; &nbsp; &nbsp; owner<br \/>\n&nbsp; <span class=\"nu0\">3<\/span> &nbsp; &nbsp;FROM DBTW054<br \/>\n&nbsp; <span class=\"nu0\">4<\/span> &nbsp; WHERE object_type<span class=\"sy0\">=<\/span><span class=\"st_h\">'x123456789y123456789z123456789w123RULE'<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nOBJECT_NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OWNER<br \/>\n<span class=\"sy0\">------------------------------<\/span> <span class=\"sy0\">----------------------------<\/span><br \/>\nSYS<span class=\"re0\">$SERVICE_METRICS<\/span>$<span class=\"nu19\">61<\/span> &nbsp; &nbsp; &nbsp; &nbsp; SYS<br \/>\nALERT_QUE$<span class=\"nu19\">1<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SYS<br \/>\nSCHEDULER<span class=\"re0\">$_EVENT_QUEUE<\/span>$<span class=\"nu19\">1<\/span> &nbsp; &nbsp; &nbsp; SYS<br \/>\nSCHEDULER<span class=\"re0\">$_EVENT_QUEUE<\/span>$<span class=\"nu19\">3<\/span> &nbsp; &nbsp; &nbsp; SYS<br \/>\n<br \/>\n<span class=\"nu0\">4<\/span> linhas selecionadas<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">--<\/span> Recupera o SQL_ID e o CHILD_NUMBER &nbsp;da consulta executada<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> column sql_id new_value m_sql_id<br \/>\nSQL <span class=\"sy0\">&gt;<\/span> column child_number new_value m_child_no<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT sql_id<span class=\"sy0\">,<\/span> child_number<br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp;FROM v<span class=\"re0\">$sql<\/span><br \/>\n&nbsp; <span class=\"nu0\">3<\/span> &nbsp; WHERE sql_text LIKE <span class=\"st_h\">'%DBTW-054.2%'<\/span><br \/>\n&nbsp; <span class=\"nu0\">4<\/span> &nbsp; &nbsp; AND sql_text NOT LIKE <span class=\"st_h\">'%v$sql%'<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nSQL_ID &nbsp; &nbsp; &nbsp; &nbsp;CHILD_NUMBER<br \/>\n<span class=\"sy0\">-------------<\/span> <span class=\"sy0\">------------<\/span><br \/>\nfm9ww6785g3dm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">0<\/span><br \/>\n<br \/>\n<span class=\"nu0\">1<\/span> linha selecionada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">--<\/span> Gera o relatorio <span class=\"kw1\">do<\/span> plano de execucao da consulta<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT <span class=\"sy0\">*<\/span> FROM TABLE <span class=\"br0\">&#40;<\/span>dbms_xplan<span class=\"sy0\">.<\/span>display_cursor <span class=\"br0\">&#40;<\/span><span class=\"st_h\">'&amp;m_sql_id'<\/span><span class=\"sy0\">,&amp;<\/span>m_child_no<span class=\"sy0\">,<\/span><span class=\"st_h\">'typical iostats last'<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nPLAN_TABLE_OUTPUT<br \/>\n<span class=\"sy0\">-------------------------------------------------------------------------------------------------------------------------------------------------------------<\/span><br \/>\nSQL_ID &nbsp;fm9ww6785g3dm<span class=\"sy0\">,<\/span> child number <span class=\"nu0\">0<\/span><br \/>\n<span class=\"sy0\">-------------------------------------<\/span><br \/>\nSELECT <span class=\"coMULTI\">\/* DBTW-054.2 *\/<\/span> object_name<span class=\"sy0\">,<\/span> &nbsp; &nbsp; &nbsp; &nbsp;owner &nbsp; FROM DBTW054 &nbsp;WHERE<br \/>\nobject_type<span class=\"sy0\">=:<\/span><span class=\"st0\">&quot;SYS_B_0&quot;<\/span><br \/>\n<br \/>\nPlan <a href=\"http:\/\/www.php.net\/hash\"><span class=\"kw3\">hash<\/span><\/a> value<span class=\"sy0\">:<\/span> <span class=\"nu0\">87264188<\/span><br \/>\n<br \/>\n<span class=\"sy0\">-------------------------------------------------------------------------------------------------------------------------------------<\/span><br \/>\n<span class=\"sy0\">|<\/span> Id &nbsp;<span class=\"sy0\">|<\/span> Operation &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">|<\/span> Name &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">|<\/span> Starts <span class=\"sy0\">|<\/span> E<span class=\"sy0\">-<\/span>Rows <span class=\"sy0\">|<\/span>E<span class=\"sy0\">-<\/span>Bytes<span class=\"sy0\">|<\/span> Cost <span class=\"br0\">&#40;<\/span><span class=\"sy0\">%<\/span>CPU<span class=\"br0\">&#41;<\/span><span class=\"sy0\">|<\/span> E<span class=\"sy0\">-<\/span><a href=\"http:\/\/www.php.net\/time\"><span class=\"kw3\">Time<\/span><\/a> &nbsp; <span class=\"sy0\">|<\/span> A<span class=\"sy0\">-<\/span>Rows <span class=\"sy0\">|<\/span> &nbsp; A<span class=\"sy0\">-<\/span><a href=\"http:\/\/www.php.net\/time\"><span class=\"kw3\">Time<\/span><\/a> &nbsp; <span class=\"sy0\">|<\/span> Buffers <span class=\"sy0\">|<\/span><br \/>\n<span class=\"sy0\">-------------------------------------------------------------------------------------------------------------------------------------<\/span><br \/>\n<span class=\"sy0\">|<\/span> &nbsp; <span class=\"nu0\">0<\/span> <span class=\"sy0\">|<\/span> SELECT STATEMENT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">1<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; <span class=\"sy0\">|<\/span> &nbsp; &nbsp; <span class=\"nu0\">4<\/span> <span class=\"br0\">&#40;<\/span><span class=\"nu0\">100<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">4<\/span> <span class=\"sy0\">|<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu19\">00.01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; <span class=\"nu0\">6<\/span> <span class=\"sy0\">|<\/span><br \/>\n<span class=\"sy0\">|<\/span> &nbsp; <span class=\"nu0\">1<\/span> <span class=\"sy0\">|<\/span> &nbsp;TABLE ACCESS BY INDEX ROWID<span class=\"sy0\">|<\/span> DBTW054 &nbsp; &nbsp; <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">1<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; <span class=\"nu0\">16<\/span> <span class=\"sy0\">|<\/span> &nbsp;<span class=\"nu0\">1184<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; <span class=\"nu0\">4<\/span> &nbsp; <span class=\"br0\">&#40;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">|<\/span> <span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">4<\/span> <span class=\"sy0\">|<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu19\">00.01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; <span class=\"nu0\">6<\/span> <span class=\"sy0\">|<\/span><br \/>\n<span class=\"sy0\">|*<\/span> &nbsp;<span class=\"nu0\">2<\/span> <span class=\"sy0\">|<\/span> &nbsp; INDEX <a href=\"http:\/\/www.php.net\/range\"><span class=\"kw3\">RANGE<\/span><\/a> SCAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"sy0\">|<\/span> DBTW054_IDX <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">1<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; <span class=\"nu0\">16<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; <span class=\"sy0\">|<\/span> &nbsp; &nbsp; <span class=\"nu0\">1<\/span> &nbsp; <span class=\"br0\">&#40;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">|<\/span> <span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp;<span class=\"nu0\">4<\/span> <span class=\"sy0\">|<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu8\">00<\/span><span class=\"sy0\">:<\/span><span class=\"nu19\">00.01<\/span> <span class=\"sy0\">|<\/span> &nbsp; &nbsp; &nbsp; <span class=\"nu0\">3<\/span> <span class=\"sy0\">|<\/span><br \/>\n<span class=\"sy0\">-------------------------------------------------------------------------------------------------------------------------------------<\/span><br \/>\n<br \/>\nPredicate Information <span class=\"br0\">&#40;<\/span>identified by operation id<span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><br \/>\n<span class=\"sy0\">---------------------------------------------------<\/span><br \/>\n<br \/>\n&nbsp; &nbsp;<span class=\"nu0\">2<\/span> <span class=\"sy0\">-<\/span> access<span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;OBJECT_TYPE&quot;<\/span><span class=\"sy0\">=:<\/span>SYS_B_0<span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n<br \/>\n<span class=\"nu0\">20<\/span> linhas selecionadas<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><br \/>\nSQL <span class=\"sy0\">&gt;<\/span> SELECT column_name<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">2<\/span> &nbsp; &nbsp; &nbsp; &nbsp; num_distinct<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">3<\/span> &nbsp; &nbsp; &nbsp; &nbsp; density<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">4<\/span> &nbsp; &nbsp; &nbsp; &nbsp; num_nulls<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">5<\/span> &nbsp; &nbsp; &nbsp; &nbsp; histogram<span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"nu0\">6<\/span> &nbsp; &nbsp; &nbsp; &nbsp; num_buckets<br \/>\n&nbsp; <span class=\"nu0\">7<\/span> &nbsp; &nbsp;FROM user_tab_col_statistics<br \/>\n&nbsp; <span class=\"nu0\">8<\/span> &nbsp; WHERE table_name <span class=\"sy0\">=<\/span> <span class=\"st_h\">'DBTW054'<\/span><br \/>\n&nbsp; <span class=\"nu0\">9<\/span> &nbsp; &nbsp; AND column_name<span class=\"sy0\">=<\/span><span class=\"st_h\">'OBJECT_TYPE'<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\nCOLUMN_NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NUM_DISTINCT &nbsp; &nbsp; &nbsp;DENSITY &nbsp;NUM_NULLS HISTOGRAM &nbsp; &nbsp; &nbsp; NUM_BUCKETS<br \/>\n<span class=\"sy0\">------------------------------<\/span> <span class=\"sy0\">------------<\/span> <span class=\"sy0\">------------<\/span> <span class=\"sy0\">----------<\/span> <span class=\"sy0\">---------------<\/span> <span class=\"sy0\">-----------<\/span><br \/>\nOBJECT_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">22<\/span> &nbsp; <span class=\"nu19\">.045454545<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">0<\/span> NONE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"nu0\">1<\/span><br \/>\n<br \/>\n<span class=\"nu0\">1<\/span> linha selecionada<span class=\"sy0\">.<\/span><br \/>\n<br \/>\nSQL <span class=\"sy0\">&gt;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 12pt;\">Ap\u00f3s a exclus\u00e3o do histograma podemos verificar que a estimativa de cardinalidade melhorou (E-ROWS=16) e ficou mais pr\u00f3xima da quantidade de linhas selecionas (A-ROWS=4), com isso o Otimizador considerou que a leitura das linhas utilizando um \u00edndice seria mais eficiente.<\/span><\/p>\n<h2 style=\"text-align: justify;\"><span style=\"font-size: 14pt;\">Refer\u00eancias<\/span><\/h2>\n<p><strong><span style=\"font-size: 12pt;\"><a href=\"https:\/\/docs.oracle.com\/cd\/E11882_01\/server.112\/e41573\/stats.htm#PFGRF30103\">https:\/\/docs.oracle.com\/cd\/E11882_01\/server.112<\/a><\/span><\/strong><br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n<a href=\"http:\/\/dbtimewizard.com.br\/treinamento\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-1255\" src=\"http:\/\/dbtimewizard.com.br\/blog\/wp-content\/uploads\/2018\/10\/promo_cur02.jpg\" alt=\"Promo-D75L\" width=\"330\" height=\"242\" \/><\/a><\/p>\n<p><a href=\"https:\/\/youtu.be\/l6OphhTle9I\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1215\" src=\"http:\/\/dbtimewizard.com.br\/wp-content\/uploads\/2018\/01\/video-02-300x168.jpg\" alt=\"video-02\" width=\"330\" height=\"242\" \/><\/a><br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>O uso de histogramas ajuda o Otimizador a ser mais preciso no c\u00e1lculo da cardinalidade das opera\u00e7\u00f5es no plano de execu\u00e7\u00e3o, mas existem situa\u00e7\u00f5es em que n\u00e3o devemos utiliz\u00e1-los, pois eles v\u00e3o induzir o Otimizador a criar planos de execu\u00e7\u00e3o de baixa qualidade. Neste artigo vamos mostrar uma destas situa\u00e7\u00f5es onde o Otimizador realiza um c\u00e1lculo de cardinalidade muito ruim,<\/p>\n","protected":false},"author":2,"featured_media":1744,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[163,162,161,82,10],"class_list":["post-1743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-estatisticas","tag-dbms_stats","tag-histogramas","tag-histograms","tag-optimizer","tag-otimizador"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"V. J.A.\"\/>\n\t<link rel=\"canonical\" href=\"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"pt_BR\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DBTimeWizard | Manter seus Bancos de Dados e Aplica\u00e7\u00f5es com alto desempenho \u00e9 o nosso neg\u00f3cio.\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Histogramas: Quando devemos evita-los? | DBTimeWizard\" \/>\n\t\t<meta property=\"og:description\" content=\"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho.\" \/>\n\t\t<meta property=\"og:url\" content=\"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2018-08-09T13:18:18+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-11-11T21:43:49+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Histogramas: Quando devemos evita-los? | DBTimeWizard\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#article\",\"name\":\"Histogramas: Quando devemos evita-los? | DBTimeWizard\",\"headline\":\"Histogramas: Quando devemos evit\\u00e1-los?\",\"author\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/author\\\/vjaquino\\\/#author\"},\"publisher\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/naousehistograms.jpg\",\"width\":669,\"height\":504,\"caption\":\"n\\u00e3o use histogramas\"},\"datePublished\":\"2018-08-09T10:18:18-03:00\",\"dateModified\":\"2019-11-11T18:43:49-03:00\",\"inLanguage\":\"pt-BR\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#webpage\"},\"isPartOf\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#webpage\"},\"articleSection\":\"Estat\\u00edsticas, DBMS_STATS, Histogramas, Histograms, Optimizer, Otimizador\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog#listItem\",\"position\":1,\"name\":\"In\\u00edcio\",\"item\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/category\\\/estatisticas\\\/#listItem\",\"name\":\"Estat\\u00edsticas\"}},{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/category\\\/estatisticas\\\/#listItem\",\"position\":2,\"name\":\"Estat\\u00edsticas\",\"item\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/category\\\/estatisticas\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#listItem\",\"name\":\"Histogramas: Quando devemos evit\\u00e1-los?\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog#listItem\",\"name\":\"In\\u00edcio\"}},{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#listItem\",\"position\":3,\"name\":\"Histogramas: Quando devemos evit\\u00e1-los?\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/category\\\/estatisticas\\\/#listItem\",\"name\":\"Estat\\u00edsticas\"}}]},{\"@type\":\"Organization\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/#organization\",\"name\":\"DBTimeWizard\",\"description\":\"Manter seus Bancos de Dados e Aplica\\u00e7\\u00f5es com alto desempenho \\u00e9 o nosso neg\\u00f3cio.\",\"url\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/author\\\/vjaquino\\\/#author\",\"url\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/author\\\/vjaquino\\\/\",\"name\":\"V. J.A.\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0ebfb24510db8dc34abd17c6b4afddd99d8e48dc9184002bc49b2fc6d324d68f?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"V. J.A.\"}},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#webpage\",\"url\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/\",\"name\":\"Histogramas: Quando devemos evita-los? | DBTimeWizard\",\"description\":\"Neste artigo abordamos uma das situa\\u00e7\\u00f5es em que a utiliza\\u00e7\\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\\u00e7\\u00e3o e faz com que ele crie uma plano de execu\\u00e7\\u00e3o de baixo desempenho.\",\"inLanguage\":\"pt-BR\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#breadcrumblist\"},\"author\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/author\\\/vjaquino\\\/#author\"},\"creator\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/author\\\/vjaquino\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/naousehistograms.jpg\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#mainImage\",\"width\":669,\"height\":504,\"caption\":\"n\\u00e3o use histogramas\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/histogramas-quando-devemos-evita-los\\\/#mainImage\"},\"datePublished\":\"2018-08-09T10:18:18-03:00\",\"dateModified\":\"2019-11-11T18:43:49-03:00\"},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/#website\",\"url\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/\",\"name\":\"DBTimeWizard\",\"description\":\"Manter seus Bancos de Dados e Aplica\\u00e7\\u00f5es com alto desempenho \\u00e9 o nosso neg\\u00f3cio.\",\"inLanguage\":\"pt-BR\",\"publisher\":{\"@id\":\"http:\\\/\\\/dbtimewizard.com.br\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Histogramas: Quando devemos evita-los? | DBTimeWizard","description":"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho.","canonical_url":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#article","name":"Histogramas: Quando devemos evita-los? | DBTimeWizard","headline":"Histogramas: Quando devemos evit\u00e1-los?","author":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/author\/vjaquino\/#author"},"publisher":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/#organization"},"image":{"@type":"ImageObject","url":"http:\/\/dbtimewizard.com.br\/blog\/wp-content\/uploads\/2018\/08\/naousehistograms.jpg","width":669,"height":504,"caption":"n\u00e3o use histogramas"},"datePublished":"2018-08-09T10:18:18-03:00","dateModified":"2019-11-11T18:43:49-03:00","inLanguage":"pt-BR","commentCount":2,"mainEntityOfPage":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#webpage"},"isPartOf":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#webpage"},"articleSection":"Estat\u00edsticas, DBMS_STATS, Histogramas, Histograms, Optimizer, Otimizador"},{"@type":"BreadcrumbList","@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"http:\/\/dbtimewizard.com.br\/blog#listItem","position":1,"name":"In\u00edcio","item":"http:\/\/dbtimewizard.com.br\/blog","nextItem":{"@type":"ListItem","@id":"http:\/\/dbtimewizard.com.br\/blog\/category\/estatisticas\/#listItem","name":"Estat\u00edsticas"}},{"@type":"ListItem","@id":"http:\/\/dbtimewizard.com.br\/blog\/category\/estatisticas\/#listItem","position":2,"name":"Estat\u00edsticas","item":"http:\/\/dbtimewizard.com.br\/blog\/category\/estatisticas\/","nextItem":{"@type":"ListItem","@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#listItem","name":"Histogramas: Quando devemos evit\u00e1-los?"},"previousItem":{"@type":"ListItem","@id":"http:\/\/dbtimewizard.com.br\/blog#listItem","name":"In\u00edcio"}},{"@type":"ListItem","@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#listItem","position":3,"name":"Histogramas: Quando devemos evit\u00e1-los?","previousItem":{"@type":"ListItem","@id":"http:\/\/dbtimewizard.com.br\/blog\/category\/estatisticas\/#listItem","name":"Estat\u00edsticas"}}]},{"@type":"Organization","@id":"http:\/\/dbtimewizard.com.br\/blog\/#organization","name":"DBTimeWizard","description":"Manter seus Bancos de Dados e Aplica\u00e7\u00f5es com alto desempenho \u00e9 o nosso neg\u00f3cio.","url":"http:\/\/dbtimewizard.com.br\/blog\/"},{"@type":"Person","@id":"http:\/\/dbtimewizard.com.br\/blog\/author\/vjaquino\/#author","url":"http:\/\/dbtimewizard.com.br\/blog\/author\/vjaquino\/","name":"V. J.A.","image":{"@type":"ImageObject","@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0ebfb24510db8dc34abd17c6b4afddd99d8e48dc9184002bc49b2fc6d324d68f?s=96&d=mm&r=g","width":96,"height":96,"caption":"V. J.A."}},{"@type":"WebPage","@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#webpage","url":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/","name":"Histogramas: Quando devemos evita-los? | DBTimeWizard","description":"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho.","inLanguage":"pt-BR","isPartOf":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/#website"},"breadcrumb":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#breadcrumblist"},"author":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/author\/vjaquino\/#author"},"creator":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/author\/vjaquino\/#author"},"image":{"@type":"ImageObject","url":"http:\/\/dbtimewizard.com.br\/blog\/wp-content\/uploads\/2018\/08\/naousehistograms.jpg","@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#mainImage","width":669,"height":504,"caption":"n\u00e3o use histogramas"},"primaryImageOfPage":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/#mainImage"},"datePublished":"2018-08-09T10:18:18-03:00","dateModified":"2019-11-11T18:43:49-03:00"},{"@type":"WebSite","@id":"http:\/\/dbtimewizard.com.br\/blog\/#website","url":"http:\/\/dbtimewizard.com.br\/blog\/","name":"DBTimeWizard","description":"Manter seus Bancos de Dados e Aplica\u00e7\u00f5es com alto desempenho \u00e9 o nosso neg\u00f3cio.","inLanguage":"pt-BR","publisher":{"@id":"http:\/\/dbtimewizard.com.br\/blog\/#organization"}}]},"og:locale":"pt_BR","og:site_name":"DBTimeWizard | Manter seus Bancos de Dados e Aplica\u00e7\u00f5es com alto desempenho \u00e9 o nosso neg\u00f3cio.","og:type":"article","og:title":"Histogramas: Quando devemos evita-los? | DBTimeWizard","og:description":"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho.","og:url":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/","article:published_time":"2018-08-09T13:18:18+00:00","article:modified_time":"2019-11-11T21:43:49+00:00","twitter:card":"summary","twitter:title":"Histogramas: Quando devemos evita-los? | DBTimeWizard","twitter:description":"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho."},"aioseo_meta_data":{"post_id":"1743","title":"Histogramas: Quando devemos evita-los? | #site_title","description":"Neste artigo abordamos uma das situa\u00e7\u00f5es em que a utiliza\u00e7\u00e3o de histogramas confunde o Otimizador na montagem do plano de execu\u00e7\u00e3o e faz com que ele crie uma plano de execu\u00e7\u00e3o de baixo desempenho.","keywords":[{"label":"Histograms","value":"Histograms"},{"label":"Histogramas","value":"Histogramas"},{"label":"Otimizador","value":"Otimizador"},{"label":"OPTIMIZER","value":"OPTIMIZER"},{"label":"DBMS_STATS","value":"DBMS_STATS"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-12-05 15:15:18","updated":"2026-03-19 14:37:29","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"http:\/\/dbtimewizard.com.br\/blog\" title=\"In\u00edcio\">In\u00edcio<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"http:\/\/dbtimewizard.com.br\/blog\/category\/estatisticas\/\" title=\"Estat\u00edsticas\">Estat\u00edsticas<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHistogramas: Quando devemos evit\u00e1-los?\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"In\u00edcio","link":"http:\/\/dbtimewizard.com.br\/blog"},{"label":"Estat\u00edsticas","link":"http:\/\/dbtimewizard.com.br\/blog\/category\/estatisticas\/"},{"label":"Histogramas: Quando devemos evit\u00e1-los?","link":"http:\/\/dbtimewizard.com.br\/blog\/histogramas-quando-devemos-evita-los\/"}],"_links":{"self":[{"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/posts\/1743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/comments?post=1743"}],"version-history":[{"count":17,"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/posts\/1743\/revisions"}],"predecessor-version":[{"id":2074,"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/posts\/1743\/revisions\/2074"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/media\/1744"}],"wp:attachment":[{"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/media?parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/categories?post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dbtimewizard.com.br\/blog\/wp-json\/wp\/v2\/tags?post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}