diagnosing-endpoint-performance
Skill này làm gì
Skill này xem một endpoint cụ thể đang chậm, bị quá thời gian chờ hoặc tốn quá nhiều chi phí, rồi đề xuất một thay đổi cụ thể. Nó dành cho người vận hành endpoint PostHog và cần kết quả nhanh hơn hoặc rẻ hơn.
Khi nào nên dùng
- ✓Khi một endpoint chậm hoặc liên tục quá thời gian chờ và bạn muốn biết vì sao.
- ✓Khi một endpoint chạm đến giới hạn chi phí và bạn cần đưa chi phí xuống.
- ✓Khi bạn không chắc một endpoint có nên được lưu thành materialized view hay không.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/diagnosing-endpoint-performance/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Endpoint bán hàng của tôi bị quá thời gian chờ mỗi sáng. Bạn có thể tìm nguyên nhân và cho biết cần thay đổi gì không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill kiểm tra cấu hình endpoint, lịch sử phiên bản và trạng thái materialize, rồi đề xuất một thay đổi như thời gian lưu đệm dài hơn, kết quả được lưu trữ hoặc truy vấn đơn giản hơn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Skill có bao phủ toàn bộ dự án không?
Không. Nó tập trung vào một endpoint được nêu tên, còn một skill kiểm toán riêng được dùng để rà soát toàn bộ dự án.
Materialization là gì?
Đó là việc lưu kết quả endpoint thành một bảng để các lần gọi lặp lại nhanh hơn, đổi lại tốn bộ nhớ và tài nguyên tính toán.
Khi nào tôi nên dùng skill kiểm toán thay thế?
Dùng kiểm toán khi bạn muốn tìm endpoint nào cần dọn dẹp trên toàn bộ dự án.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6861
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
discrawl
394kCho phép agent của bạn tìm kiếm và tóm tắt kho lưu trữ tin nhắn Discord trên máy, kiểm tra độ mới của dữ liệu và đọc tin nhắn trực tiếp.
clickhouse-io
280kGiúp agent của bạn tối ưu truy vấn và schema trong ClickHouse theo thực hành tốt nhất cho phân tích dữ liệu hiệu năng cao khi truy vấn chậm.
scientific-db-pubmed-database
280kGiúp agent của bạn tìm bài báo khoa học trong lĩnh vực y sinh. Hữu ích cho nghiên cứu cần thông tin y khoa cụ thể.