Optimizing ClickHouse and HogQL queries Scope: this skill optimizes ClickHouse queries and HogQL queries (which compile to ClickHouse). It does not optimize Postgres / Django ORM / app-database queries. If the slow query you're holding is a or any other call against the app DB, stop and use pganalyze + the Postgres section of instead. Step 0 below has the full triage. The best way to optimize a HogQL query is to start with the ClickHouse SQL it produces, optimize that, then translate the change back into the HogQL query, the query runner, the HogQL printer, or a ClickHouse migration . Skip ah…