Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Sampling a certain percent of rows from a table!

Re: Sampling a certain percent of rows from a table!

From: Sybrand Bakker <gooiditweg_at_sybrandb.demon.nl>
Date: Sat, 24 Jan 2004 11:28:29 +0100
Message-ID: <skg410l9ii9lfvf1oi2p6uoq2rko8df4pa@4ax.com>


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 DBA
Received on Sat Jan 24 2004 - 04:28:29 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US