Confused with dbms_xplan.display

扶醉桌前 提交于 2020-01-03 05:50:07

问题


I'm using oracle 11g. Just started practicing index. For this i just created a table with 10000000 rows. With out creating index i searched for 4568754th record, in the explain plan it was displaying 28 rows only.

My doubt:

Oracle will do sequential search if we wont' create any index on the table. In the above example searched rows should be 4568743 but why it was showing 28 only?

After creating unique index it has searched only 1 row. I can see the diff in %CPU and time taken to execute but number of rows scanned only the confusion for me.

Can anyone please explain..If my understanding was wrong?


回答1:


Execution plans only show the estimated number of rows, which is based on gathered statistics. Optimizer statistics are complicated; without precise information about what was executed it's not possible to explain the ROWS value.

Most likely the table has stale or missing statistics and the estimate for a FULL TABLE SCAN is inaccurate. Index statistics are automatically gathered on creation. When the index was created and the plan changed it was able to use the accurate index statistics to predict only one row is returned.



来源:https://stackoverflow.com/questions/25091137/confused-with-dbms-xplan-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!