diagnosing-endpoint-performance
できること
このスキルは、遅い、タイムアウトする、またはコストが高すぎる特定のエンドポイントを調べ、具体的な修正を提案します。エンドポイントを運用し、より速く安く結果を得たい人向けです。
使う場面
- ✓エンドポイントが遅い、またはタイムアウトを繰り返し、原因を知りたいとき。
- ✓エンドポイントがコストの上限に達し、コストを下げる必要があるとき。
- ✓エンドポイントをマテリアライズされたビューとして保存すべきか判断できないとき。
スキルのリンク
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/diagnosing-endpoint-performance/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私の売上エンドポイントは毎朝タイムアウトします。原因と変更点を調べてもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
エンドポイントの設定、バージョンの履歴、マテリアライズの状態を確認します。その後、キャッシュを長くする、結果を保存する、クエリを簡単にするなどの変更を提案します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Diagnosing endpoint performance
This skill walks through a specific endpoint that is slow, expensive, or unreliable, and produces
a concrete recommendation. It is the deep-dive counterpart to auditing-endpoints (which finds
candidates).
When to use this skill
- "This endpoint is slow / timing out"
- "Why is my endpoint hitting the cost cap?"
- "Should I materialise X?"
- An endpoint surfaced from
auditing-endpointsas a failing materialisation or expensive caller - The user has a specific endpoint in mind and wants advice
If the question is project-wide ("what should I clean up?"), use auditing-endpoints first.
Available tools
| Tool | Purpose |
|---|---|
endpoint-get |
Full endpoint config: query, current version, data_freshness_seconds, materialisation status |
endpoint-versions |
History of every version (query + materialisation state); which version is current |
endpoint-materialization-status |
Whether materialisation is eligible, current state, last run, last error |
endpoints-materialization-preview |
What the materialised query would look like, plus the rejection reason if ineligible |
endpoints-last-execution-times |
When was it last called (endpoint-level sanity-check that it is in active use) |
execute-sql |
Query query_log for endpoint-level call frequency and per-call duration/bytes |
The decision tree
When deciding what to recommend, walk these in order — the first one that applies is the cheapest fix.
Step 1 — Is it cached at all?
Fetch the endpoint and look at data_freshness_seconds (it sets both the cache TTL and, when
materialised, the refresh cadence). If the user's traffic
calls the same parameters repeatedly within that window, every call after the first is a cache
hit and effectively free.
- TTL is at the default (24h / 86400s) and the data really doesn't need fresher than that → done, no change needed.
- TTL is at the 900s floor (15 min) and the user is hitting the endpoint many times per minute →
bump the TTL. This is almost always the cheapest first move. (
data_freshness_secondsis an enum: 900, 1800, 3600, 21600, 43200, 86400, 604800 — there is no sub-15-minute value.) - TTL is at the floor because the data must be fresh (e.g. real-time dashboard) → cache won't help, skip to step 2.
The shape of the variables matters here: if every call passes different user_id or date_from
values, the cache has many distinct keys and a higher TTL helps less. If almost every call uses
the same handful of parameter combinations, the cache helps a lot.
Step 2 — Should it be materialised?
Materialisation pre-computes the query into a saved view that's refreshed on a schedule. Reads become near-instant — at the cost of staleness equal to the refresh interval, plus storage and compute for the materialisation itself.
Call endpoints-materialization-preview. The response tells you:
- Eligible + clean transform → strong candidate. Recommend enabling, especially for endpoints with predictable filter shapes (variables, breakdowns).
- Not eligible, with a rejection reason → cannot materialise. The reason often hints at the next step (see step 3 — rewrite).
- Eligible but the transform is gnarly (lots of range pairs, complex aggregation re-derivation) → materialisation will work but may not save much. Worth flagging before flipping the switch.
When materialisation is enabled, callers must pass all materialised variables — calls without them are rejected (security: prevents returning unfiltered data). Pair the recommendation with a note about which variables become required.
Step 3 — Does the query need rewriting?
For a SQL endpoint that isn't eligible, the rejection reason from
endpoints-materialization-preview is the lead. That tool always resolves. Read the reason and
match it to the bullets below — they summarise the common cases, not every check the server runs,
so the raw reason wins when the two disagree. Propose the rewrite by hand:
- Cohort breakdown / compare mode rejection → regular property breakdowns materia
よくある質問
プロジェクト全体を対象にしますか?
いいえ。名前を指定した1つのエンドポイントに焦点を当てます。プロジェクト全体のレビューには、別の監査スキルを使います。
マテリアライズとは何ですか?
エンドポイントの結果をテーブルとして保存することで、繰り返し呼び出しを速くします。ただし、ストレージと計算資源を使います。
代わりに監査スキルを使うべきなのはどんなときですか?
プロジェクト全体で、整理すべきエンドポイントを見つけたいときは、監査スキルを使います。
詳細
作者による元の説明
Diagnose why a PostHog endpoint is slow or expensive and propose a concrete fix — bump the cache TTL, enable materialisation, restructure variables, or rewrite the query. Use when the user says "this endpoint is slow", "my endpoint times out", "we're hitting the cost cap on this one", or asks "should I materialise this?". Focuses on a single named endpoint, not a project-wide audit.
repo: PostHog/posthog
人気
- GitHubのスター
- 41k
- ランキング
- #6861
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
depot-ci
41kエージェントが、GitHub Actionsの代替であるDepot CIのワークフローを設定し実行できるよう支援します。既存のワークフローの移行や、実行ログの確認も含みます。
depot-container-builds
41kエージェントが、Depotのリモート・ビルダーでDockerイメージを作れるよう支援します。マルチプラットフォームのイメージ、レジストリへのプッシュ、ビルド失敗の修正を含みます。
depot-github-runners
41kエージェントが、GitHub Actionsのジョブを Depot が管理するランナーに移し、ランナーのサイズとラベルを選び、ランナー設定の問題を解決できるよう支援します。
editing-agents-md
41kエージェントが、AGENTS.mdとCLAUDE.mdのどちらにルールを書くべきかを判断し、ファイルを膨らませずに守られやすい形で書けるよう支援します。
似ているスキル
discrawl
394k保存済みのローカルなDiscordメッセージのアーカイブを検索して要約し、その新しさを確認し、ダイレクトメッセージを読めるようエージェントを支援します。
clickhouse-io
280kエージェントがClickHouseデータベースのクエリとスキーマを最適化できるようにします。高性能な分析処理向けのベストプラクティスを適用します。分析クエリが遅すぎるときに使います。
scientific-db-pubmed-database
280kエージェントが生物医学分野の科学論文を検索するのに役立ちます。特定の医療情報が必要な研究に便利です。