# Native random sampling in ClickHouse

DevFeed: [Native random sampling in ClickHouse](<https://devfeed.tech/articles/native-random-sampling-in-clickhouse-5439.md>)

Original publisher: [Read original article](<https://clickhouse.com/blog/native-random-sampling>)

Author: Mark Needham

Published: 2026-05-22T09:53:15Z

Content type: tutorial

Language: en

Sources: [ClickHouse Blog](<https://devfeed.tech/sources/clickhouse-blog.md>)

Topics: [clickhouse](<https://devfeed.tech/topics/clickhouse.md>), [datasets](<https://devfeed.tech/topics/datasets.md>), [data](<https://devfeed.tech/topics/data.md>)

Tags: [clickhouse](<https://devfeed.tech/tags/clickhouse.md>), [data](<https://devfeed.tech/tags/data.md>), [datasets](<https://devfeed.tech/tags/datasets.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [learn](<https://devfeed.tech/tags/learn.md>), [uk](<https://devfeed.tech/tags/uk.md>)

## AI overview

This tutorial explains how to use ClickHouse native random sampling and the SAMPLE BY clause to run faster approximate aggregate queries on large datasets. Using the UK house prices dataset, it shows how to choose a high-cardinality, evenly distributed sampling key and why postcode combinations work better than a low-cardinality county column.

## Source excerpt

Learn how to use ClickHouse's SAMPLE BY clause to run fast, approximate queries on large datasets with minimal accuracy trade-off.