[PoC] Decide which ClickHouse gem to use

The main goal is to use the ClickHouse database the same way we use the PostgreSQL database. We need to support the following use cases:

  • ActiveRecord / or other model support (repository pattern)
  • Query generation building capabilities. (Escaping, composable queries)
  • Migration and schema management.

Task

  • Look into the options for accessing ClickHouse from a Rails application and document the required steps.
  • Assess and compare the listed GEM candidates and provide pros-cons.
  • Define follow-up tasks.

GEM candidates

click_house

  • Doesn't use ActiveRecord.
  • Works without any code changes in the GitLab application.
  • Lack of schema management/migrations.
  • Quirky AR support.

clickhouse-activerecord

  • ActiveRecord adapter for ClickHouse.
  • Couldn't test it with the GitLab application thoroughly.
  • We have a lot of PG-specific patches to the ActiveRecord::Base class which breaks non-PG adapters.
  • With some changes, querying the DB worked. The migration part was broken.

Use PG adapter

I haven't tested it, but it seems like it's possible to use the PG wire protocol with CH: https://clickhouse.com/docs/en/interfaces/postgresql/

Edited by Adam Hegyi