A Beginner's Guide to ClickHouse in Ruby on Rails
When you build a standard Rails app, PostgreSQL (or MySQL) is your best friend. It handles your users, your posts, and your billing perfectly. But what happens when you want to track analytics? Let...

Source: DEV Community
When you build a standard Rails app, PostgreSQL (or MySQL) is your best friend. It handles your users, your posts, and your billing perfectly. But what happens when you want to track analytics? Let's say you want to track every single time a user clicks a button, views a page, or triggers an API event. Very quickly, you will have millions (or billions) of rows. If you try to run Event.where(action: 'click').count on a PostgreSQL table with 50 million rows, your database will choke, your app will slow down, and your users will get annoyed. This is where ClickHouse comes in. What is ClickHouse and Why Use It? ClickHouse is an open-source database specifically built for analytics. It is ridiculously fast. Queries that take 30 seconds in Postgres can take 0.05 seconds in ClickHouse. How does it do this? It stores data by Columns, not by Rows. Postgres (Row-based): If you ask Postgres to sum up the price of all orders, it pulls every single order row from the hard drive, looks at the price,