I need to select random rows from my sql table, when search this cases in google, they suggested to order by NEWID() but it reduce the performance, Since my table have more 2000000 data it not suit for me.
And i tried below code for get random data
SELECT TOp 10 * FROM Table1
WHERE (ABS(CAST(
(BINARY_CHECKSUM(*) *
RAND()) as int)) % 100) < 10
It also drop performance some time, Could you please suggest good solution for get random data from my table, i need minimum rows from that tables like 30 rows for each request, i tried TableSAMPLE for get the data but it return nothing once i added my where condition because it return the data by the basis of page not basis of row.
Aucun commentaire:
Enregistrer un commentaire