0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 09:16:49 +01:00
posthog/ee/clickhouse
James Greenhill ab0c75414b
Make settings dynamic for MATERIALIZED_COLUMNS_ENABLED (#7662)
* Make settings dynamic for MATERIALIZED_COLUMNS_ENABLED

* migrate MATERIALIZED_COLUMNS_ENABLED to this and test

* allow tests that use materialized columns to hit django model for settings

* nicer installed apps config

* update snapshot from test

* make test_property more deterministic

Co-authored-by: James Greenhill <fuzionech@gmail.com>
Co-authored-by: yakkomajuri <yakko.majuri@gmail.com>
2021-12-14 17:56:08 -08:00
..
bin
materialized_columns Make settings dynamic for MATERIALIZED_COLUMNS_ENABLED (#7662) 2021-12-14 17:56:08 -08:00
migrations Create and populate person_distinct_id2 table, add versioning to person_distinct_id (#7576) 2021-12-08 16:47:57 +02:00
models Make settings dynamic for MATERIALIZED_COLUMNS_ENABLED (#7662) 2021-12-14 17:56:08 -08:00
queries Experiment Results Detail Page (#7606) 2021-12-14 12:37:36 +00:00
sql [actors] retention actors (#7495) 2021-12-09 10:11:21 -05:00
test Revert "Add logging to all postgresql queries with query context (#7486)" (#7512) 2021-12-03 12:07:19 -08:00
views Resolve another insights N+1 issue (#7628) 2021-12-10 14:57:05 +01:00
__init__.py
client.py Fix issue blocking clickhouse migrations on new installs (#7516) 2021-12-03 15:42:19 -08:00
demo.py Update mypy and typed-ast, fail early if db version not in range (#7599) 2021-12-10 09:29:04 +01:00
errors.py
generate_local.py
middleware.py Revert "Add logging to all postgresql queries with query context (#7486)" (#7512) 2021-12-03 12:07:19 -08:00
README.md
system_status.py
timer.py
util.py Add snapshot tests for clickhouse table schemas (#7572) 2021-12-08 16:07:34 +02:00

Clickhouse Support (Enterprise Feature)

To accomodate high volume deployments, Posthog can use Clickhouse instead of Postgres. Clickhouse isn't used by default because Postgres is easier to deploy and maintain on smaller instances and on platforms such as Heroku.

Clickhouse Support works by swapping in separate queries and classes in the system for models that are most impacted by high volume usage (ex: events and actions).

Migrations and Models

The django_clickhouse orm is used to manage migrations and models. The ORM is used to mimic the django model and migration structure in the main folder.

Certain migrations (e.g. changing table engines) can be quite expensive and tricky, especially for deployments outside of cloud. To skip these steps during deployment setup, check for the CLICKHOUSE_INITIAL_MIGRATIONS environment variable.

If you need help in making them happen, ask for help from team deployments.

Queries

Queries parallel the queries folder in the main folder however, clickhouse queries are written in SQL and do not utilize the ORM.

Tests

The tests are inherited from the main folder. The Clickhouse query classes are based off BaseQuery so their run function should work just as the Django ORM backed query classes. These classes are called with the paramterized tests declared in the main folder which allows the same suite of tests to be run with different implementations.

Views

Views contain Viewset classes that are not backed by models. Instead the views query Clickhouse tables using SQL. These views match the interface provide by the views in the main folder.