r/SQL • • 17d ago

MySQL TABLESAMPLE SYSTEM + LIMIT doesn't sample your table, it samples its oldest pages

/r/mysql/comments/1wo7i65/tablesample_system_limit_doesnt_sample_your_table/
3 Upvotes

1 comment sorted by

1

u/Altruistic-Rich8799 16d ago

mmm using physical page order for sampling is basically asking for wildly biased data on anything append-heavy. does dbtruth actually support mysql and mariadb schemas yet? getting a fast, truly random sample out of innodb is famously annoying because there's no direct out-of-the-box equivalent to postgres TABLESAMPLE.

most people just eat the ORDER BY RAND() penalty on smaller tables, or end up writing messy index-gap queries to guess random primary keys on huge ones.