问题
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