& Nbsp;
<Table cellspacing = "0" cellpadding = "0">
<Tbody>
<Tr>
<TD id = "postmessage_1459845"> try this statement, select * from (select * from test sample (1) where rownum & lt; 201;
Can be compared with the jianfs method, as follows:
SQL & gt; select count (*) from test; count (*)
----------
20000
1 row selected.
SQL & gt; analyze table test compute statistics;
Table analyzed.
SQL & gt; Set autotrace traceonly
SQL & gt; select * from (select * from test order by dbms_random.random () where rownum & lt; 201;
200 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT statement optimizer = choose (cost = <span style = "color: red;"> 1850 [/color] card = 20000 byte
(S = 2560000) </span>
1 0 count (stopkey)
2 1 View (cost = 1850 card = 20000 bytes = 2560000)
3 2 sort (order by stopkey) (cost = 1850 card = 20000 bytes = 17
00000)
4 3 Table Access (full) of 'test' (cost = 230 card = 20000 B
Ytes = 1700000)
Statistics
----------------------------------------------------------
<Span style = "color: red;"> 483 [/color] recursive cballs
<Span style = "color: red;"> 82 [/color] db block gets
1657 consistent gets
503 physical reads
<Span style = "color: red;"> 9068 [/color] redo size
28898 bytes sent via SQL * Net to client
1958 bytes encoded ed via SQL * Net From Client
16 SQL * Net roundtrips to/from client
3 sorts (memory)
1 sorts (Disk)
200 rows processed </span>
SQL & gt; select * from (select * from test sample (1) where rownum & lt; 201;
200 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT statement optimizer = choose (cost = <span style = "color: red;"> 230 [/color] card = 200 bytes = 1
(7000) </span>
1 0 count (stopkey)
2 1 Table Access (sample) of 'test' (cost = 230 card = 200 bytes
= 17000)
Statistics
----------------------------------------------------------
<Span style = "color: red;"> 3 [/color] recursive cballs
<Span style = "color: red;"> 8 [/color] db block gets
<Span style = "color: red;"> 1507 [/color] consistent gets
0 physical reads
<Span style = "color: red;"> 0 [/color] redo size
26488 bytes sent via SQL * Net to client
1937 bytes encoded ed via SQL * Net From Client
16 SQL * Net roundtrips to/from client
2 sorts (memory)
0 sorts (Disk)
200 rows processed </span>
& Nbsp;
& Nbsp; </TD>
</Tr>
</Tbody>
</Table>
Sample is not an analysis function, and 1 in the brackets of a SELECT statement indicates sampling 1%.