CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

optimizing-clickhouse-and-hogql-queries

Workflow for optimizing ClickHouse and HogQL queries. Use when a HogQL query, query runner, insight, or report is too slow; when a hand-written ClickHouse query (via `sync_execute` or in a migration) is too slow; when ClickHouse times out or hits memory limits; when investigating a slow `system.query_log` row; or when reviewing a proposed HogQL printer change for performance. Covers extracting the ClickHouse SQL, common smells (`FROM ... FINAL`, `JSONExtract` over properties, missing skip indexes, self-joins, CTE blow-up), measuring against a real cluster, and applying the fix at the right layer (printer, query runner, or migration). Does NOT cover Postgres / Django ORM / app-database queries; for those use `profiling-slow-api-endpoints`.

73

Quality

92%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

—

The risk profile of this skill

SKILL.md
Quality
Evals
Security

Quality

Content

85%Weight 40%Scale 1-5

Reviews the quality of instructions and guidance provided to agents. Good implementation is clear, handles edge cases, and produces reliable results.

The body is a high-quality, domain-specific guide: actionable rewrites, a well-sequenced workflow with validation, and lean expert knowledge. Its main weakness is progressive disclosure — it points readers to references/ files that are not present in the bundle.

Suggestions

Add the missing references/investigation-playbook.md and references/learnings.md files referenced in the body (Step 2 and the Learnings log section), or remove/inline the links so no navigation path dead-ends.

Tighten the repeated single-team-vs-multi-team raw-SQL argument in Step 0 into a single statement to cut length without losing the rule.

Consider moving the dense Background file-path listing into a references file so the SKILL.md overview stays scannable, with the existing links pointing at real files.

DimensionReasoningScore

Conciseness

Dense with PostHog-specific knowledge Claude lacks (exact file paths, line numbers, named rewrites, printer internals) with no padding about what ClickHouse/HogQL are; but at ~170 lines some prose recurs (e.g. the single-team-vs-multi-team raw-SQL argument is restated across Step 0) and could be tightened.

4 / 5

Actionability

Provides copy-paste-ready rewrites ('SELECT argMax(properties, version) FROM person WHERE ... GROUP BY id', 'sumIf(amount, event=\'purchase\')', 'replace every JSONExtract*(properties, \'X\') with properties.X'), exact EXPLAIN invocations, and specific migration/printer entry points with line numbers covering the common cases.

5 / 5

Workflow Clarity

A clear Step 0 → Step 5 sequence fronted by a triage table, with explicit validation checkpoints: assert index use via 'get_index_from_explain', 'Measure before suggesting' with before/after query_duration_ms/read_bytes, and test discipline that says to 'flip the change off to confirm the test exercises your path'.

5 / 5

Progressive Disclosure

Structure and reference signaling are good (explicit markdown links, one-level-deep pointers to references/investigation-playbook.md and references/learnings.md), but those referenced files do not exist — the references/ directory is absent — so navigation leads to dead ends rather than a properly split bundle.

3 / 5

Total

17

/

20

Passed

Description

100%Weight 40%Scale 1-5

Based on the skill's description, can an agent find and select it at the right time? Clear, specific descriptions lead to better discovery.

The description is third-person, concise, and tightly scoped: it states concrete capabilities, gives multiple natural trigger phrases, and draws a clear boundary against the Postgres/Django skill. It is a strong, low-conflict description.

DimensionReasoningScore

Specificity

Lists multiple concrete actions — 'extracting the ClickHouse SQL', scanning for named smells ('FROM ... FINAL', 'JSONExtract over properties', 'missing skip indexes', 'self-joins', 'CTE blow-up'), 'measuring against a real cluster', and 'applying the fix at the right layer (printer, query runner, or migration)' — giving comprehensive coverage.

5 / 5

Completeness

Explicitly answers both 'what' (a workflow covering extraction, smell-scanning, measuring, and fix application) and 'when' via repeated concrete 'Use when ...' trigger clauses, plus a negative-scope clause.

5 / 5

Trigger Term Quality

Natural phrases a user would actually say appear throughout — 'a HogQL query, query runner, insight, or report is too slow', 'ClickHouse times out or hits memory limits', 'investigating a slow system.query_log row', 'reviewing a proposed HogQL printer change for performance' — with synonyms and technical markers covered.

5 / 5

Distinctiveness Conflict Risk

Occupies a clear niche (ClickHouse/HogQL) and explicitly disambiguates from the adjacent skill — 'Does NOT cover Postgres / Django ORM / app-database queries; for those use profiling-slow-api-endpoints' — minimizing wrong-skill triggering.

5 / 5

Total

20

/

20

Passed

Validation

87%

Checks the skill against the spec for correct structure and formatting. All validation checks must pass before discovery and implementation can be scored.

Validation — 14 / 16 Passed

Validation for skill structure

CriteriaDescriptionResult

relative_links

Relative link issues: 3 missing, 49 suspicious

Warning

referenced_paths_exist

Referenced path issues: 6 missing

Warning

Total

14

/

16

Passed

Repository

PostHog/posthog

Path

.agents/skills/optimizing-clickhouse-and-hogql-queries/SKILL.md

Reviewed

Table of Contents

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.