diagnosing-endpoint-performance
What it does
This skill looks at one specific endpoint that is slow, timing out or costing too much, and recommends a concrete fix. It is for people who run PostHog endpoints and need faster or cheaper results.
When to use it
- βWhen an endpoint is slow or keeps timing out and you want to know why.
- βWhen an endpoint is hitting its cost limit and you need to bring the cost down.
- βWhen you are not sure whether an endpoint should be stored as a materialized view.
Skill link
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/diagnosing-endpoint-performance/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βMy sales endpoint times out every morning. Can you find out why and what to change?β
5 new skills a week. 1 minute to read.
How it works
It checks the endpoint's configuration, version history and materialization status, then recommends a change such as a longer cache, stored results or a simpler query.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Does it cover the whole project?
No. It focuses on one named endpoint, and a separate audit skill is used to review the whole project.
What is materialization?
It stores the endpoint's results as a table so repeated calls are faster, at the cost of storage and compute.
When should I use the audit skill instead?
Use the audit when you want to find which endpoints to clean up across the whole project.
Details
Original description by the author
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
Popularity
- GitHub stars
- 41k
- Ranking position
- #6861
- License
- β
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
depot-ci
41kHelps your agent set up and run Depot CI workflows, a GitHub Actions alternative, including migrating existing workflows and reading run logs.
depot-container-builds
41kHelps your agent build Docker images on Depot's remote builders, including multi-platform images, pushing to registries, and fixing build failures.
depot-github-runners
41kHelps your agent move GitHub Actions jobs to Depot-managed runners, choosing runner sizes and labels, and troubleshooting runner setup issues.
editing-agents-md
41kHelps your agent decide whether a rule belongs in an AGENTS.md or CLAUDE.md file, and write it so it sticks without bloating the file.
Similar skills
discrawl
394kLets your agent search and summarize a saved local archive of Discord messages, check how fresh it is, and read direct messages.
clickhouse-io
280kHelps your agent optimize queries and schemas in ClickHouse databases. It applies best practices for high-performance analytical workloads. Use when analytical queries are too slow.
scientific-db-pubmed-database
280kHelps your agent search for scientific articles in the biomedical field. It's useful for research needing specific medical information.