Details
-
New Feature
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
Description
It is recommended to implement oracle's sample clause in MariaDB of sql_mode=oracle
SAMPLE [ BLOCK ]
(sample_percent)
[ SEED (seed_value) ]
The sample_clause lets you instruct the database to select from a random sample of data from the table, rather than from the entire table.
- BLOCK instructs the database to attempt to perform random block sampling instead of random row sampling.
- For sample_percent, specify the percentage of the total row or block count to be included in the sample.
- SEED seed_value Specify this to instruct the database to attempt to return the same sample from one execution to the next.
oracle sample clause and example: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SELECT.html#GUID-CFA006CA-6FF1-4972-821E-6996142A51C6
How is this used syntax used the application?
Why doesn't the following work good enough?
SELECT * from t1 where rand() < 0.1 LIMIT 1000?
This returns 10% of the rows up to 1000 rows.
It would not be hard to implement the BLOCK syntax but internally replace it with WHERE rand() < X for the tables we do table scans on.