This question asks about getting a random(ish) sample of records on SQL Server and the answer was to use TABLESAMPLE
. Is there an equivalent in Oracle 10?
This in not a perfect answer but will get much better performance.
SELECT *
FROM (
SELECT *
FROM mytable sample (0.01)
ORDER BY
dbms_random.value
)
WHERE rownum <= 1000
Sample will give you a percent of your actual table, if you really wanted a 1000 rows you would need to adjust that number. More often I just need an arbitrary number of rows anyway so I don't limit my results. On my database with 2 million rows I get 2 seconds vs 60 seconds.
select * from mytable sample (0.01)