Skip to main content
In this tutorial you’ll explore ClickHouse using the which contains data of prices paid for real-estate property in England and Wales since 1995.

Prerequisites

For this tutorial, you’ll need:
1

Create the table

  1. Select SQL console from the the left hand menu
  2. Click the + tab next to the home icon to create a new query
  3. In the SQL editor type the following query, then click Run:
Take note of ORDER BY (postcode1, postcode2, addr1, addr2) which defines how ClickHouse sorts data on disk. Choosing an effective primary key in ClickHouse which matches your access patterns is crucial for query performance and storage efficiency. See “Choosing a primary key” for more details.
See https://www.gov.uk for a description of the fields.
2

Preprocess and insert the data

You can use the url function to stream data into ClickHouse. Some preprocess is required first. The query below inserts 25+ million rows into the uk_price_paid table and performs the following preprocessing steps:
  • splits the postcode to two different columns - postcode1 and postcode2, which is better for storage and queries
  • converts the time field to date as it only contains 00:00 time
  • ignores the UUID field because it isn’t needed for analysis
  • transforms type and duration to more readable Enum fields using the transform function
  • transforms the is_new field from a single-character string (Y/N) to a UInt8 field with 0 or 1
  • drops the last two columns since they all have the same value (which is 0)
Wait for the data to insert - it will take a minute or two depending on the network speed.
3

Validate the data

Let’s verify it worked by seeing how many rows were inserted:
At the time this query was run, the dataset had 27,450,499 rows. Let’s see what the storage size is of the table in ClickHouse:
Notice the size of the table is just 221.43 MiB, while the original dataset in uncompressed form is about 4 GiB. ClickHouse offers excellent data compression out of the box, but also allows you to further tune compression per column if you need.
4

Run some queries

With the data loaded, try out the following queries to get a sense of how fast analytical queries return results. The query below finds the average price per year across all of the data:
The query below applies a filter to find the average price per year in London:
It looks like something happened to home prices in 2020! But that is probably not a surprise…The query below finds the most expensive neighborhoods:

Next steps

In this tutorial you created a table, preprocessed and loaded UK property price data into ClickHouse, and then ran some analytical queries on that data. Next you can:
Last modified on September 22, 2026