Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Sampling a certain percent of rows from a table!
On 23 Jan 2004 23:10:50 -0800, asif30779_at_yahoo.com (Asif Haider)
wrote:
>Can someone explain the following. The total number of rows in the
>table is 14. So sampling 50% should always give me a count of 7,
>right? But notice that it shows different outputs for the same same
>query. Am I being mistaken somewhere?
It is a sample isn't it? So why does a sample -for which the number of
records really doesn't matter- always need to return an exact number
of records?
Also, as the SAMPLE clause requires CBO my bet is the optimizer will
use the associated statistics on the table to determine the number of
records returned. It isn't likely the optimizer would perform a full
table scan prior to the sample to determine the accurate number of
records. So: if you want an accurate number, you should probably make
sure your statistics are accurate, and/or find other techniques with
formal predicates.
-- Sybrand Bakker, Senior Oracle DBAReceived on Sat Jan 24 2004 - 04:28:29 CST
![]() |
![]() |