Insights have different data from the Clickhouse db
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start by reproducing the supplied ClickHouse query for the 2024-06-25 date and compare its results with the Trends and SQL insight views. Investigate why adding count(distinct person_id) changes the event count, using the attached screenshots and the self-hosted Docker Compose context. Done means the discrepancy is explained and the affected insight behavior is corrected or clearly documented.
Written by the indexing model from the issue text.
Description
Bug Description
Bug description
While running a query on the Clickhouse client, it gives me results very different from what I get on the Posthog insights. Be it trends or SQL insight. It is giving me a third of what i get from the client.
Here's the query I'm running.
SELECT
count(e.uuid),
count(distinct distinct_id),
count(distinct person_id)
FROM
events e
where
e.event = '$pageview'
and e.created_at >= toDateTime('2024-06-25 00:00:00', 'Asia/Kolkata')
and e.created_at <= toDateTime('2024-06-25 23:59:59', 'Asia/Kolkata')
Additional context
In the screenshots added, please notice that the count for events is 87k in sql and 232k in trends. In the sql insight if i remove the count for person_id the count of event matches the one in trends. This is really bizarre to me.
Running the above query on the clickhouse client gives me
Screenshots for SQL insight and trends are attached:
Screenshot from clickhouse client:
Debug info
- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables]
- [x] PostHog self-hosted with `docker compose`, version/commit: []
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]
- Dominant language
- Python
- Stars
- 39.9k
- Forks
- 3.4k
- Avg merge
- 7h 27m
- Merged PRs (30d)
- 222
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PostHog/posthog
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
MotherDuck incremental sync never checks for duplicate primary keys, so the guard is a dead branch Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100