본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)41k · #6984

clickhouse-autoresearch-campaign

하는 일

이 스킬은 ClickHouse에서 데이터베이스 쿼리 하나의 속도를 높이기 위한 체계적인 작업을 에이전트가 진행하도록 안내합니다. 쿼리 변경을 반복적으로 안전하게 시험하면서 결과를 기록하려는 엔지니어를 위한 스킬입니다.

사용하는 경우

  • ✓측정 가능한 반복 시도를 통해 ClickHouse 쿼리 하나를 빠르게 만들고 싶을 때.
  • ✓각 쿼리 실험을 자체 git 브랜치에 보관하고 싶을 때.
  • ✓쿼리 변경에 대한 기준 시간과 정확성 검사 기록을 원할 때.

스킬 링크

https://github.com/PostHog/posthog/blob/master/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/PostHog/posthog/blob/master/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“ClickHouse 대시보드의 쿼리가 너무 느립니다. 자체 브랜치에서 최적화 캠페인을 실행하고, 각 시도를 기록해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 전용 브랜치와 작업 공간을 설정하고, 시작 기준선을 측정합니다. 아이디어를 한 번에 하나씩 시도하며, 결과가 계속 맞는지 확인하고, 개선이 멈춘 시도의 기록을 검토합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

ClickHouse Autoresearch Campaign

This skill packages the orchestration for optimizing one ClickHouse query on one git branch.

Required reads

Before taking action, read orchestration.md (sibling of this file) completely. Treat it as the operating contract.

Preconditions

This skill assumes:

  • pi-autoresearch is installed and its tools are available
  • the current directory is a git repository
  • you have a target query or enough context to identify one
  • the operator will provide or help configure .clickhouse-autoresearch/adapter.json

Branch rule

One campaign = one git branch.

If the current branch is not a dedicated campaign branch yet, create one before initializing the workspace.

Workspace rule

Use a single workspace at:

.clickhouse-autoresearch/

The branch is the campaign boundary. The workspace is just the artifact layout.

If autoresearch.config.json exists in the current working directory, read its workingDir field and use that path as the workspace instead of the default above. Automated orchestrators (for example PostHog's run_campaign.py) initialize the workspace at /tmp/autoresearch-campaign/ and write the config alongside it.

Pre-initialized workspace detection

Before doing anything in the Setup sequence, check whether the workspace has already been prepared by an external orchestrator. If the resolved workspace contains all of:

  • adapter.json
  • baseline/metrics.json
  • query/original.sql

…then the workspace is pre-initialized. In that case:

  • Skip the entire Setup sequence (steps 1–6). Do not ask the operator for a target query, connection details, or anything else — the orchestrator has already supplied them.
  • Jump directly to step 7 of the Setup sequence (read the baseline and seed the first lanes and hypotheses), then continue with steps 8–9 and the normal campaign loop.
  • Operate headlessly: at no point prompt the operator for input. If a decision requires judgment, apply the skill's default guidance and record the choice in state.json / autoresearch.md.

Only fall back to the interactive Setup sequence below when the workspace is empty or partially initialized.

Adapter capabilities (what you can and cannot run)

Campaign queries flow through the adapter configured in adapter.json. Every campaign script (ch_capture_baseline.py, ch_run_candidate.py, any ad-hoc probe) ultimately submits SQL through this adapter, and the adapter enforces what ClickHouse sees.

When adapter.json has type: "coordinator", your SQL is routed to whichever ClickHouse the host-side coordinator is pointed at — typically a read-only test cluster or a local dev ClickHouse. Either way the cluster runs SQL under a profile that pins readonly = 2, so writes (INSERT, ALTER, CREATE, OPTIMIZE, SYSTEM, TRUNCATE, DROP, ATTACH, DETACH) will fail with a ClickHouse error. Read GET /v1/info (or check autoresearch.md — the coordinator's prompt addendum is prepended there) before issuing any predicate that depends on a specific team_id: the prompt addendum tells you which team_id the target cluster has data for, and you must rewrite team_id predicates to match it. For experiments treat every read-only statement form as available:

  • SELECT … — arbitrary subqueries, CTEs, joins
  • WITH … SELECT …
  • EXPLAIN … — every variant ClickHouse supports. Use them before proposing rewrites:
    • EXPLAIN SELECT … (default: PLAN)
    • EXPLAIN AST SELECT …
    • EXPLAIN SYNTAX SELECT …
    • EXPLAIN QUERY TREE SELECT … (post-analyzer logical tree; invaluable on modern ClickHouse)
    • EXPLAIN PIPELINE SELECT … — processor-level pipeline, headers, expressions
    • EXPLAIN ESTIMATE SELECT … — per-part row/mark estimates before execution
    • EXPLAIN PLAN indexes = 1, actions = 1, json = 1 SELECT … — primary-key and skip-index use, JSON for machine parsing
    • EXPLAIN TABLE OVERRIDE …
  • SHOW … — SHOW CREATE TABLE events, SHOW COLUMNS FROM events, SHOW INDEX FROM events, SHOW SETTINGS ILIKE '%mark_cache%', etc.
  • DESCRIBE / DESC …

Timeout: every submission is wrapped with SETTINGS max_execution_time = 60. Keep ad-hoc probes short. If the target query itself routinely exceeds 60s, use range narrowing (see Setup step 6) and only then start the campaign.

Cluster scoping: depends on the coordinator's target. The prompt addendum prepended to autoresearch.md tells you which team_id the target cluster has data for and ask

자주 묻는 질문

자체 git 브랜치가 필요한가요?

네. 각 캠페인은 하나의 전용 git 브랜치에서 작업하며, 그것이 작업의 경계가 됩니다.

쿼리 결과가 맞는지 확인하나요?

네. 정확성 검사는 시간 테스트와 함께 실행되므로, 더 빨라진 쿼리도 올바른 답을 반환해야 합니다.

어떤 도구에 의존하나요?

pi-autoresearch 도구가 설치되어 있어야 하고, 대상 어댑터를 위한 설정 파일이 필요합니다.

상세 정보

작성자의 원본 설명

Run a ClickHouse query optimization campaign on one git branch using pi-autoresearch, dynamic lanes and hypotheses, baseline result capture, correctness checks, and stagnation-aware lane/campaign review.

repo: PostHog/posthog

인기도

GitHub 스타
41k
순위
#6984
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬