The queries below were executed on a Production instance of ClickHouse Cloud. For more information see
“Playground specifications”.
Loading the dataset
- Without inserting the data into ClickHouse, we can query it in place. Let’s grab some rows, so we can see what they look like:
- Let’s define a new
MergeTreetable namedamazon_reviewsto store this data in ClickHouse:
- The following
INSERTcommand uses thes3Clustertable function, which allows the processing of multiple S3 files in parallel using all the nodes of your cluster. We also use a wildcard to insert any file that starts with the namehttps://datasets-documentation.s3.eu-west-3.amazonaws.com/amazon_reviews/amazon_reviews_*.snappy.parquet:
- That query doesn’t take long - averaging about 300,000 rows per second. Within 5 minutes or so you should see all the rows inserted:
- Let’s see how much space our data is using:
Example queries
- Let’s run some queries. Here are the top 10 most-helpful reviews in the dataset:
This query is using a projection to speed up performance.
- Here are the top 10 products in Amazon with the most reviews:
- Here are the average review ratings per month for each product (an actual Amazon job interview question!):
- Here are the total number of votes per product category. This query is fast because
product_categoryis in the primary key:
- Let’s find the products with the word “awful” occurring most frequently in the review. This is a big task - over 151M strings have to be parsed looking for a single word:
runnable
- We can run the same query again, except this time we search for awesome in the reviews:
runnable