• Product
  • Pricing
  • Docs
  • Using PostHog
  • Community
  • Company
  • Login
  • Home
  • CEO diaries
    • After the HN launch
    • Remote companies can be too asynchronous
    • The time before YC
    • Winning from the back - late mover advantage
    • Optimize for not breaking up with your co-founder
    • Cancer and revenue - the latest board meeting
    • "How come your website is so nice?"
    • Things I learned last year
    • Our new objective: Nail Self Serve
    • How we found our Ideal Customer Profile
    • Tell me about features, not benefits
    • The magic of a Hacker News Pre-Mortem
    • How to run a transparent startup
    • How we justified quitting our jobs and financing PostHog early on
    • How we made something people want
    • Moving to San Francisco
    • Pivot to PostHog
    • Counterintuitive lessons about our pricing
    • I used to think you don't need product people. I was wrong.
    • How we raised $3M for an open source project
    • A story about pivots
    • The YC Interview
    • Raising money is less stressful than bootstrapping
    • What motivates me as a CEO
    • The really important job interview questions engineers should ask (but don't)
    • Writing for developers
    • Reflecting on YC, 2 years on
  • Company & culture
    • How we do meetings at PostHog
  • Comparisons
    • PostHog vs Matomo
    • PostHog vs Amplitude
    • Why I ditched Google Analytics and Mixpanel for PostHog
  • Engineering
    • Enabling zero downtime data migrations for self-hosted users
    • Automating a software company with GitHub Actions
    • How to speed up ClickHouse queries using materialized columns
    • In-depth: ClickHouse vs PostgreSQL
    • Setting up super fast Cypress tests on GitHub Actions
    • How I learned to love feedback loops (and make better products)
    • Frontend filters & backend SQL - A chat with Eric Duong, Sam Winslow, James Greenhill, and Buddy Williams
    • PostHog Joins Hacktoberfest 2020
    • How PostHog built an app server (from MVP to billions of events)
    • How we’re making PostHog deployments easier
    • Solving the mystery of PostHog’s missing session recordings
    • I used to think you don't need product people. I was wrong.
    • The secrets of PostHog query performance
    • Benchmarking the impact of session recording on performance
    • The state of plugins on PostHog
    • We ship whenever
  • General
    • Setting up super fast Cypress tests on GitHub Actions
    • How we designed the PostHog mascot
    • Why you may not need a sales team
    • A story about pivots
  • Guides
    • Introduction to self-service analytics
    • Building an AARRR pirate funnel (how and why)
    • 5 essential tips for Customer Success teams on PostHog
    • 5 analytics ideas for marketing teams using PostHog
    • Automating a software company with GitHub Actions
    • The most useful B2B SaaS product metrics
    • The 7 best GDPR-compliant analytics tools
    • The best HIPAA-compliant A/B testing tools
    • The 5 best free and open-source A/B testing tools
    • The 4 best HIPAA-compliant analytics tools
    • The best open-source analytics and data tools
    • Open source (and self-hosted) alternatives to Hotjar & FullStory
    • The two ways to estimate your monthly event usage
    • How to speed up ClickHouse queries using materialized columns
    • In-depth: ClickHouse vs PostgreSQL
    • Google is about to make it a lot harder to track website and app users without third-party cookies
    • Setting up super fast Cypress tests on GitHub Actions
    • 5 essential PostHog apps for new users
    • 5 events all teams should track with PostHog
    • What launching Experimentation taught us about running effective A/B tests
    • How to get the first 10 paying customers for your devtool company (and other customer acquisition tips)
    • The best GA4 alternatives for apps and websites
    • How to harness the awesome power of growth loops
    • What is user segmentation?
    • How to measure product engagement
    • How to achieve B2B product market fit
    • How to work out what your users really need
    • How we do hiring & HR at PostHog
    • How we turned ClickHouse into our event mansion
    • An introduction to customer retention
    • Is Google Analytics HIPAA compliant?
    • Finding your North Star metric and why it matters
    • How we monetized our open source devtool
    • Building an open source data stack
    • How to plan a killer company offsite in just 8 weeks
    • Permissions and projects in PostHog, explained
    • How (and why) our marketing team uses PostHog
    • PostHog vs Matomo
    • PostHog vs Amplitude
    • Product engineer vs software engineer: what's the difference?
    • Don’t bother securing your trademarks in the beginning
    • How to seed, grow, and scale Developer Relations (and how we're doing it at PostHog)
    • The ops toolkit for early-stage startups
    • How (and why) to track your website with PostHog
    • 22 ways PostHog makes it easier to build great products
    • What is a product engineer (and why they're awesome)
    • A simple guide to personal data and PII
    • An introduction to product analytics and how it works
    • What is SSO and why you should enable it for PostHog
    • The 3 critical reasons companies choose self-hosted analytics
  • HogMail
    • HogMail #14
    • HogMail #15
    • HogMail #16
    • HogMail #17: The personal traits that can't be taught
    • HogMail #18: What can SaaS learn from the New York Times?
  • Inside PostHog
    • PostHog raises $15 million Series B for open source product analytics
    • A non-coders thoughts on ‘Everybody Codes’ - Part Two
    • A non-coder's thoughts on an 'Everybody Codes' culture
    • After the HN launch
    • Remote companies can be too asynchronous
    • The time before YC
    • How PostHog uses Wren to offset carbon emissions during offsites
    • Winning from the back - late mover advantage
    • Optimize for not breaking up with your co-founder
    • Cancer and revenue - the latest board meeting
    • "How come your website is so nice?"
    • Things I learned last year
    • Our new objective: Nail Self Serve
    • How we found our Ideal Customer Profile
    • How we do customer support at our open source devtool company
    • The importance of dogfooding - Why product managers should use their product as much as their users
    • How we designed the PostHog mascot
    • Using Gatsby and Puppeteer to create dynamic Open Graph images
    • Creating an employee-friendly startup share option scheme
    • Tell me about features, not benefits
    • How I learned to love feedback loops (and make better products)
    • The magic of a Hacker News Pre-Mortem
    • HostHogs - free drinks, free pizza and frequently asked questions
    • How to run a transparent startup
    • How we do hiring & HR at PostHog
    • How PostHog built an app server (from MVP to billions of events)
    • How we turned ClickHouse into our event mansion
    • How we justified quitting our jobs and financing PostHog early on
    • Introducing Phil Leggetter, our new head of Developer Relations
    • Using Google Analytics was deemed 'illegal' in some EU countries. We built a microsite in 48 hours to capitalize on the news.
    • Introducing Joe Martin - Our first Product Marketer
    • How we made something people want
    • How we do meetings at PostHog
    • Solving the mystery of PostHog’s missing session recordings
    • Moving to San Francisco
    • How PostHog's new VP focused the company on nailing funnels in his first week
    • An engineer's guide to picking a cofounder
    • Pivot to PostHog
    • How to plan a killer company offsite in just 8 weeks
    • PostHog raises $12 million in funding led by GV and Y Combinator
    • What we learned about hiring from our first five employees
    • How (and why) our marketing team uses PostHog
    • How we rebranded PostHog in four weeks - a postmortem
    • Counterintuitive lessons about our pricing
    • I used to think you don't need product people. I was wrong.
    • What's the true role of a product team at an engineering-led organization?
    • Building an all-remote company from scratch
    • How we raised $3M for an open source project
    • All the cool things we built at our Rome hackathon
    • Content marketing strategy for devtool companies - How we do it at PostHog
    • How to seed, grow, and scale Developer Relations (and how we're doing it at PostHog)
    • Benchmarking the impact of session recording on performance
    • Speeding up PostHog builds with Depot
    • How to run finance at your startup without hiring a finance person
    • How to choose job titles in your early stage startup
    • Startups, stop treating engineers like a different species
    • The ops toolkit for early-stage startups
    • A story about pivots
    • The YC Interview
    • Why we ditched ‘talk to sales’ for transparent pricing
    • Raising money is less stressful than bootstrapping
    • What motivates me as a CEO
    • The really important job interview questions engineers should ask (but don't)
    • Why I ditched Google Analytics and Mixpanel for PostHog
    • Why infrastructure is a competitive advantage for us
    • Why we raised a $15m Series B ahead of schedule
    • Writing for developers
    • Reflecting on YC, 2 years on
    • YC adds PostHog to top valued companies for July 2021
  • Launch week
    • Introducing Collaboration for PostHog
    • Introducing Data Management for PostHog
    • What launching Experimentation taught us about running effective A/B tests
    • How we’re making PostHog deployments easier
    • PostHog Launch Week I: A Universe of New Features
    • The secrets of PostHog query performance
  • Open source
    • The Early Days of GitLab - A Chat with Sid Sijbrandij
    • The 5 best free and open-source A/B testing tools
    • The 6 best free and open-source feature flag tools
    • The best open-source analytics and data tools
    • Open source (and self-hosted) alternatives to Hotjar & FullStory
    • How we do customer support at our open source devtool company
    • How I learned to love feedback loops (and make better products)
    • PostHog Joins Hacktoberfest 2020
    • Give Back Friday with PostHog
    • Building an open source data science publishing platform - An interview with Datapane CEO, Leo Anthias
    • How we monetized our open source devtool
    • Open source is eating SaaS
    • Building an open source data stack
    • Should open source projects track you?
    • PostHog vs Amplitude
    • How we raised $3M for an open source project
    • Why open-source projects are essential for large businesses
    • Send love to open-source projects on Valentine's Day
    • Speeding up PostHog builds with Depot
    • The 3 critical reasons companies choose self-hosted analytics
  • PostHog Academy
    • What is user segmentation?
    • How to measure product engagement
    • How to achieve B2B product market fit
    • How to work out what your users really need
    • An introduction to customer retention
    • An introduction to product analytics and how it works
  • Privacy
    • The 7 best GDPR-compliant analytics tools
    • The best HIPAA-compliant A/B testing tools
    • The 4 best HIPAA-compliant analytics tools
    • Google is about to make it a lot harder to track website and app users without third-party cookies
    • A new 'Privacy Shield' won't solve big tech's GDPR problem
    • Is Google Analytics HIPAA compliant?
    • A simple guide to personal data and PII
  • Product analytics
    • Introduction to self-service analytics
    • Building an AARRR pirate funnel (how and why)
    • The two ways to estimate your monthly event usage
    • How to harness the awesome power of growth loops
    • What is user segmentation?
    • How to measure product engagement
    • How to achieve B2B product market fit
    • How to work out what your users really need
    • An introduction to customer retention
    • Is autocapture ‘still’ bad?
    • Finding your North Star metric and why it matters
    • How PostHog's new VP focused the company on nailing funnels in his first week
    • What's the true role of a product team at an engineering-led organization?
    • How to turn your engineers into product people
    • 22 ways PostHog makes it easier to build great products
    • An introduction to product analytics and how it works
  • Product updates
    • Why we're giving away 100 times more cloud usage, free
    • Enabling zero downtime data migrations for self-hosted users
    • Introducing the Avo Inspector app
    • We just made PostHog Open Source 1000x more scalable via ClickHouse
    • Introducing Collaboration for PostHog
    • Introducing Data Management for PostHog
    • What launching Experimentation taught us about running effective A/B tests
    • Group Analytics is now available in PostHog
    • You can now reverse ETL into PostHog with Hightouch
    • How we’re making PostHog deployments easier
    • PostHog Launch Week I: A Universe of New Features
    • How we’re improving performance by combining persons and events
    • PostHog teams up with Altinity
    • Introducing PostHog Cloud EU
    • Restack joins the PostHog Marketplace
    • PostHog is now available on Segment!
    • The secrets of PostHog query performance
    • Why we're removing the sessions page
    • Array 1.0.10
    • Array 1.0.11
    • Array 1.0.8
    • Array 1.0.9
    • Array 1.1.0
    • Array 1.11.0
    • Array 1.10.0
    • Array 1.12.0
    • Array 1.13.0
    • Array 1.14.0
    • Array 1.15.0
    • Array 1.16.0
    • Array 1.17.0
    • Array 1.18.0
    • Array 1.2.0
    • Array 1.19.0
    • Array 1.20.0
    • Array 1.22.0
    • Array 1.21.0
    • Array 1.23.0
    • Array 1.24.0
    • Array 1.25.0
    • Array 1.27.0
    • Array 1.28.0
    • Array 1.29.0
    • Array 1.26.0
    • Array 1.3.0
    • Array 1.30.0
    • Array 1.31.0
    • Array 1.32.0
    • Array 1.33.0
    • Array 1.34.0
    • Array 1.35.0: Introducing SAML, world map view and new plugins
    • Array 1.37.0: Cohorts 2.0 and event & property detail pages
    • Array 1.36.0: Introducing AND/OR filtering, timezone support and universal search
    • Array 1.38.0: Exports, subscriptions and session analysis
    • Array 1.39.0: Betas, persons, events and libraries
    • Array 1.4.0
    • Array 1.40.0: Interface improvements and more!
    • Array 1.42.0: Get beta features via our roadmap!
    • Array 1.5.0
    • Array 1.41.0: Improving performance by up to 400%
    • Array 1.6.0
    • Array 1.7.0
    • Array 1.8.0
    • Array 1.9.0
    • Array 1.0.0
    • The state of plugins on PostHog
  • Release notes
    • Introducing the Avo Inspector app
    • How we’re improving performance by combining persons and events
    • Array 1.0.10
    • Array 1.0.11
    • Array 1.0.8
    • Array 1.0.9
    • Array 1.1.0
    • Array 1.11.0
    • Array 1.10.0
    • Array 1.12.0
    • Array 1.13.0
    • Array 1.14.0
    • Array 1.15.0
    • Array 1.16.0
    • Array 1.17.0
    • Array 1.18.0
    • Array 1.2.0
    • Array 1.19.0
    • Array 1.20.0
    • Array 1.22.0
    • Array 1.21.0
    • Array 1.23.0
    • Array 1.24.0
    • Array 1.25.0
    • Array 1.27.0
    • Array 1.28.0
    • Array 1.29.0
    • Array 1.26.0
    • Array 1.3.0
    • Array 1.30.0
    • Array 1.31.0
    • Array 1.32.0
    • Array 1.33.0
    • Array 1.34.0
    • Array 1.35.0: Introducing SAML, world map view and new plugins
    • Array 1.37.0: Cohorts 2.0 and event & property detail pages
    • Array 1.36.0: Introducing AND/OR filtering, timezone support and universal search
    • Array 1.38.0: Exports, subscriptions and session analysis
    • Array 1.39.0: Betas, persons, events and libraries
    • Array 1.4.0
    • Array 1.40.0: Interface improvements and more!
    • Array 1.42.0: Get beta features via our roadmap!
    • Array 1.5.0
    • Array 1.41.0: Improving performance by up to 400%
    • Array 1.6.0
    • Array 1.7.0
    • Array 1.8.0
    • Array 1.9.0
    • Array 1.0.0
  • Startups
    • A non-coder's thoughts on an 'Everybody Codes' culture
    • How we found our Ideal Customer Profile
    • Creating an employee-friendly startup share option scheme
    • How to get the first 10 paying customers for your devtool company (and other customer acquisition tips)
    • How to run a transparent startup
    • Building an open source data science publishing platform - An interview with Datapane CEO, Leo Anthias
    • How we made something people want
    • How we monetized our open source devtool
    • Should open source projects track you?
    • An engineer's guide to picking a cofounder
    • How to plan a killer company offsite in just 8 weeks
    • What we learned about hiring from our first five employees
    • How we rebranded PostHog in four weeks - a postmortem
    • Product engineer vs software engineer: what's the difference?
    • What's the true role of a product team at an engineering-led organization?
    • Why you may not need a sales team
    • Don’t bother securing your trademarks in the beginning
    • Building an all-remote company from scratch
    • All the cool things we built at our Rome hackathon
    • Content marketing strategy for devtool companies - How we do it at PostHog
    • Why open-source projects are essential for large businesses
    • How to run finance at your startup without hiring a finance person
    • How to choose job titles in your early stage startup
    • Startups, stop treating engineers like a different species
    • The ops toolkit for early-stage startups
    • How to turn your engineers into product people
    • Raising money is less stressful than bootstrapping
    • What is a product engineer (and why they're awesome)
    • Writing for developers
    • Reflecting on YC, 2 years on
  • Using PostHog
    • 5 essential tips for Customer Success teams on PostHog
    • 5 analytics ideas for marketing teams using PostHog
    • 5 essential PostHog apps for new users
    • 5 events all teams should track with PostHog
    • Permissions and projects in PostHog, explained
    • How (and why) our marketing team uses PostHog
    • How (and why) to track your website with PostHog
    • What is SSO and why you should enable it for PostHog
  • Home
  • CEO diaries
    • After the HN launch
    • Remote companies can be too asynchronous
    • The time before YC
    • Winning from the back - late mover advantage
    • Optimize for not breaking up with your co-founder
    • Cancer and revenue - the latest board meeting
    • "How come your website is so nice?"
    • Things I learned last year
    • Our new objective: Nail Self Serve
    • How we found our Ideal Customer Profile
    • Tell me about features, not benefits
    • The magic of a Hacker News Pre-Mortem
    • How to run a transparent startup
    • How we justified quitting our jobs and financing PostHog early on
    • How we made something people want
    • Moving to San Francisco
    • Pivot to PostHog
    • Counterintuitive lessons about our pricing
    • I used to think you don't need product people. I was wrong.
    • How we raised $3M for an open source project
    • A story about pivots
    • The YC Interview
    • Raising money is less stressful than bootstrapping
    • What motivates me as a CEO
    • The really important job interview questions engineers should ask (but don't)
    • Writing for developers
    • Reflecting on YC, 2 years on
  • Company & culture
    • How we do meetings at PostHog
  • Comparisons
    • PostHog vs Matomo
    • PostHog vs Amplitude
    • Why I ditched Google Analytics and Mixpanel for PostHog
  • Engineering
    • Enabling zero downtime data migrations for self-hosted users
    • Automating a software company with GitHub Actions
    • How to speed up ClickHouse queries using materialized columns
    • In-depth: ClickHouse vs PostgreSQL
    • Setting up super fast Cypress tests on GitHub Actions
    • How I learned to love feedback loops (and make better products)
    • Frontend filters & backend SQL - A chat with Eric Duong, Sam Winslow, James Greenhill, and Buddy Williams
    • PostHog Joins Hacktoberfest 2020
    • How PostHog built an app server (from MVP to billions of events)
    • How we’re making PostHog deployments easier
    • Solving the mystery of PostHog’s missing session recordings
    • I used to think you don't need product people. I was wrong.
    • The secrets of PostHog query performance
    • Benchmarking the impact of session recording on performance
    • The state of plugins on PostHog
    • We ship whenever
  • General
    • Setting up super fast Cypress tests on GitHub Actions
    • How we designed the PostHog mascot
    • Why you may not need a sales team
    • A story about pivots
  • Guides
    • Introduction to self-service analytics
    • Building an AARRR pirate funnel (how and why)
    • 5 essential tips for Customer Success teams on PostHog
    • 5 analytics ideas for marketing teams using PostHog
    • Automating a software company with GitHub Actions
    • The most useful B2B SaaS product metrics
    • The 7 best GDPR-compliant analytics tools
    • The best HIPAA-compliant A/B testing tools
    • The 5 best free and open-source A/B testing tools
    • The 4 best HIPAA-compliant analytics tools
    • The best open-source analytics and data tools
    • Open source (and self-hosted) alternatives to Hotjar & FullStory
    • The two ways to estimate your monthly event usage
    • How to speed up ClickHouse queries using materialized columns
    • In-depth: ClickHouse vs PostgreSQL
    • Google is about to make it a lot harder to track website and app users without third-party cookies
    • Setting up super fast Cypress tests on GitHub Actions
    • 5 essential PostHog apps for new users
    • 5 events all teams should track with PostHog
    • What launching Experimentation taught us about running effective A/B tests
    • How to get the first 10 paying customers for your devtool company (and other customer acquisition tips)
    • The best GA4 alternatives for apps and websites
    • How to harness the awesome power of growth loops
    • What is user segmentation?
    • How to measure product engagement
    • How to achieve B2B product market fit
    • How to work out what your users really need
    • How we do hiring & HR at PostHog
    • How we turned ClickHouse into our event mansion
    • An introduction to customer retention
    • Is Google Analytics HIPAA compliant?
    • Finding your North Star metric and why it matters
    • How we monetized our open source devtool
    • Building an open source data stack
    • How to plan a killer company offsite in just 8 weeks
    • Permissions and projects in PostHog, explained
    • How (and why) our marketing team uses PostHog
    • PostHog vs Matomo
    • PostHog vs Amplitude
    • Product engineer vs software engineer: what's the difference?
    • Don’t bother securing your trademarks in the beginning
    • How to seed, grow, and scale Developer Relations (and how we're doing it at PostHog)
    • The ops toolkit for early-stage startups
    • How (and why) to track your website with PostHog
    • 22 ways PostHog makes it easier to build great products
    • What is a product engineer (and why they're awesome)
    • A simple guide to personal data and PII
    • An introduction to product analytics and how it works
    • What is SSO and why you should enable it for PostHog
    • The 3 critical reasons companies choose self-hosted analytics
  • HogMail
    • HogMail #14
    • HogMail #15
    • HogMail #16
    • HogMail #17: The personal traits that can't be taught
    • HogMail #18: What can SaaS learn from the New York Times?
  • Inside PostHog
    • PostHog raises $15 million Series B for open source product analytics
    • A non-coders thoughts on ‘Everybody Codes’ - Part Two
    • A non-coder's thoughts on an 'Everybody Codes' culture
    • After the HN launch
    • Remote companies can be too asynchronous
    • The time before YC
    • How PostHog uses Wren to offset carbon emissions during offsites
    • Winning from the back - late mover advantage
    • Optimize for not breaking up with your co-founder
    • Cancer and revenue - the latest board meeting
    • "How come your website is so nice?"
    • Things I learned last year
    • Our new objective: Nail Self Serve
    • How we found our Ideal Customer Profile
    • How we do customer support at our open source devtool company
    • The importance of dogfooding - Why product managers should use their product as much as their users
    • How we designed the PostHog mascot
    • Using Gatsby and Puppeteer to create dynamic Open Graph images
    • Creating an employee-friendly startup share option scheme
    • Tell me about features, not benefits
    • How I learned to love feedback loops (and make better products)
    • The magic of a Hacker News Pre-Mortem
    • HostHogs - free drinks, free pizza and frequently asked questions
    • How to run a transparent startup
    • How we do hiring & HR at PostHog
    • How PostHog built an app server (from MVP to billions of events)
    • How we turned ClickHouse into our event mansion
    • How we justified quitting our jobs and financing PostHog early on
    • Introducing Phil Leggetter, our new head of Developer Relations
    • Using Google Analytics was deemed 'illegal' in some EU countries. We built a microsite in 48 hours to capitalize on the news.
    • Introducing Joe Martin - Our first Product Marketer
    • How we made something people want
    • How we do meetings at PostHog
    • Solving the mystery of PostHog’s missing session recordings
    • Moving to San Francisco
    • How PostHog's new VP focused the company on nailing funnels in his first week
    • An engineer's guide to picking a cofounder
    • Pivot to PostHog
    • How to plan a killer company offsite in just 8 weeks
    • PostHog raises $12 million in funding led by GV and Y Combinator
    • What we learned about hiring from our first five employees
    • How (and why) our marketing team uses PostHog
    • How we rebranded PostHog in four weeks - a postmortem
    • Counterintuitive lessons about our pricing
    • I used to think you don't need product people. I was wrong.
    • What's the true role of a product team at an engineering-led organization?
    • Building an all-remote company from scratch
    • How we raised $3M for an open source project
    • All the cool things we built at our Rome hackathon
    • Content marketing strategy for devtool companies - How we do it at PostHog
    • How to seed, grow, and scale Developer Relations (and how we're doing it at PostHog)
    • Benchmarking the impact of session recording on performance
    • Speeding up PostHog builds with Depot
    • How to run finance at your startup without hiring a finance person
    • How to choose job titles in your early stage startup
    • Startups, stop treating engineers like a different species
    • The ops toolkit for early-stage startups
    • A story about pivots
    • The YC Interview
    • Why we ditched ‘talk to sales’ for transparent pricing
    • Raising money is less stressful than bootstrapping
    • What motivates me as a CEO
    • The really important job interview questions engineers should ask (but don't)
    • Why I ditched Google Analytics and Mixpanel for PostHog
    • Why infrastructure is a competitive advantage for us
    • Why we raised a $15m Series B ahead of schedule
    • Writing for developers
    • Reflecting on YC, 2 years on
    • YC adds PostHog to top valued companies for July 2021
  • Launch week
    • Introducing Collaboration for PostHog
    • Introducing Data Management for PostHog
    • What launching Experimentation taught us about running effective A/B tests
    • How we’re making PostHog deployments easier
    • PostHog Launch Week I: A Universe of New Features
    • The secrets of PostHog query performance
  • Open source
    • The Early Days of GitLab - A Chat with Sid Sijbrandij
    • The 5 best free and open-source A/B testing tools
    • The 6 best free and open-source feature flag tools
    • The best open-source analytics and data tools
    • Open source (and self-hosted) alternatives to Hotjar & FullStory
    • How we do customer support at our open source devtool company
    • How I learned to love feedback loops (and make better products)
    • PostHog Joins Hacktoberfest 2020
    • Give Back Friday with PostHog
    • Building an open source data science publishing platform - An interview with Datapane CEO, Leo Anthias
    • How we monetized our open source devtool
    • Open source is eating SaaS
    • Building an open source data stack
    • Should open source projects track you?
    • PostHog vs Amplitude
    • How we raised $3M for an open source project
    • Why open-source projects are essential for large businesses
    • Send love to open-source projects on Valentine's Day
    • Speeding up PostHog builds with Depot
    • The 3 critical reasons companies choose self-hosted analytics
  • PostHog Academy
    • What is user segmentation?
    • How to measure product engagement
    • How to achieve B2B product market fit
    • How to work out what your users really need
    • An introduction to customer retention
    • An introduction to product analytics and how it works
  • Privacy
    • The 7 best GDPR-compliant analytics tools
    • The best HIPAA-compliant A/B testing tools
    • The 4 best HIPAA-compliant analytics tools
    • Google is about to make it a lot harder to track website and app users without third-party cookies
    • A new 'Privacy Shield' won't solve big tech's GDPR problem
    • Is Google Analytics HIPAA compliant?
    • A simple guide to personal data and PII
  • Product analytics
    • Introduction to self-service analytics
    • Building an AARRR pirate funnel (how and why)
    • The two ways to estimate your monthly event usage
    • How to harness the awesome power of growth loops
    • What is user segmentation?
    • How to measure product engagement
    • How to achieve B2B product market fit
    • How to work out what your users really need
    • An introduction to customer retention
    • Is autocapture ‘still’ bad?
    • Finding your North Star metric and why it matters
    • How PostHog's new VP focused the company on nailing funnels in his first week
    • What's the true role of a product team at an engineering-led organization?
    • How to turn your engineers into product people
    • 22 ways PostHog makes it easier to build great products
    • An introduction to product analytics and how it works
  • Product updates
    • Why we're giving away 100 times more cloud usage, free
    • Enabling zero downtime data migrations for self-hosted users
    • Introducing the Avo Inspector app
    • We just made PostHog Open Source 1000x more scalable via ClickHouse
    • Introducing Collaboration for PostHog
    • Introducing Data Management for PostHog
    • What launching Experimentation taught us about running effective A/B tests
    • Group Analytics is now available in PostHog
    • You can now reverse ETL into PostHog with Hightouch
    • How we’re making PostHog deployments easier
    • PostHog Launch Week I: A Universe of New Features
    • How we’re improving performance by combining persons and events
    • PostHog teams up with Altinity
    • Introducing PostHog Cloud EU
    • Restack joins the PostHog Marketplace
    • PostHog is now available on Segment!
    • The secrets of PostHog query performance
    • Why we're removing the sessions page
    • Array 1.0.10
    • Array 1.0.11
    • Array 1.0.8
    • Array 1.0.9
    • Array 1.1.0
    • Array 1.11.0
    • Array 1.10.0
    • Array 1.12.0
    • Array 1.13.0
    • Array 1.14.0
    • Array 1.15.0
    • Array 1.16.0
    • Array 1.17.0
    • Array 1.18.0
    • Array 1.2.0
    • Array 1.19.0
    • Array 1.20.0
    • Array 1.22.0
    • Array 1.21.0
    • Array 1.23.0
    • Array 1.24.0
    • Array 1.25.0
    • Array 1.27.0
    • Array 1.28.0
    • Array 1.29.0
    • Array 1.26.0
    • Array 1.3.0
    • Array 1.30.0
    • Array 1.31.0
    • Array 1.32.0
    • Array 1.33.0
    • Array 1.34.0
    • Array 1.35.0: Introducing SAML, world map view and new plugins
    • Array 1.37.0: Cohorts 2.0 and event & property detail pages
    • Array 1.36.0: Introducing AND/OR filtering, timezone support and universal search
    • Array 1.38.0: Exports, subscriptions and session analysis
    • Array 1.39.0: Betas, persons, events and libraries
    • Array 1.4.0
    • Array 1.40.0: Interface improvements and more!
    • Array 1.42.0: Get beta features via our roadmap!
    • Array 1.5.0
    • Array 1.41.0: Improving performance by up to 400%
    • Array 1.6.0
    • Array 1.7.0
    • Array 1.8.0
    • Array 1.9.0
    • Array 1.0.0
    • The state of plugins on PostHog
  • Release notes
    • Introducing the Avo Inspector app
    • How we’re improving performance by combining persons and events
    • Array 1.0.10
    • Array 1.0.11
    • Array 1.0.8
    • Array 1.0.9
    • Array 1.1.0
    • Array 1.11.0
    • Array 1.10.0
    • Array 1.12.0
    • Array 1.13.0
    • Array 1.14.0
    • Array 1.15.0
    • Array 1.16.0
    • Array 1.17.0
    • Array 1.18.0
    • Array 1.2.0
    • Array 1.19.0
    • Array 1.20.0
    • Array 1.22.0
    • Array 1.21.0
    • Array 1.23.0
    • Array 1.24.0
    • Array 1.25.0
    • Array 1.27.0
    • Array 1.28.0
    • Array 1.29.0
    • Array 1.26.0
    • Array 1.3.0
    • Array 1.30.0
    • Array 1.31.0
    • Array 1.32.0
    • Array 1.33.0
    • Array 1.34.0
    • Array 1.35.0: Introducing SAML, world map view and new plugins
    • Array 1.37.0: Cohorts 2.0 and event & property detail pages
    • Array 1.36.0: Introducing AND/OR filtering, timezone support and universal search
    • Array 1.38.0: Exports, subscriptions and session analysis
    • Array 1.39.0: Betas, persons, events and libraries
    • Array 1.4.0
    • Array 1.40.0: Interface improvements and more!
    • Array 1.42.0: Get beta features via our roadmap!
    • Array 1.5.0
    • Array 1.41.0: Improving performance by up to 400%
    • Array 1.6.0
    • Array 1.7.0
    • Array 1.8.0
    • Array 1.9.0
    • Array 1.0.0
  • Startups
    • A non-coder's thoughts on an 'Everybody Codes' culture
    • How we found our Ideal Customer Profile
    • Creating an employee-friendly startup share option scheme
    • How to get the first 10 paying customers for your devtool company (and other customer acquisition tips)
    • How to run a transparent startup
    • Building an open source data science publishing platform - An interview with Datapane CEO, Leo Anthias
    • How we made something people want
    • How we monetized our open source devtool
    • Should open source projects track you?
    • An engineer's guide to picking a cofounder
    • How to plan a killer company offsite in just 8 weeks
    • What we learned about hiring from our first five employees
    • How we rebranded PostHog in four weeks - a postmortem
    • Product engineer vs software engineer: what's the difference?
    • What's the true role of a product team at an engineering-led organization?
    • Why you may not need a sales team
    • Don’t bother securing your trademarks in the beginning
    • Building an all-remote company from scratch
    • All the cool things we built at our Rome hackathon
    • Content marketing strategy for devtool companies - How we do it at PostHog
    • Why open-source projects are essential for large businesses
    • How to run finance at your startup without hiring a finance person
    • How to choose job titles in your early stage startup
    • Startups, stop treating engineers like a different species
    • The ops toolkit for early-stage startups
    • How to turn your engineers into product people
    • Raising money is less stressful than bootstrapping
    • What is a product engineer (and why they're awesome)
    • Writing for developers
    • Reflecting on YC, 2 years on
  • Using PostHog
    • 5 essential tips for Customer Success teams on PostHog
    • 5 analytics ideas for marketing teams using PostHog
    • 5 essential PostHog apps for new users
    • 5 events all teams should track with PostHog
    • Permissions and projects in PostHog, explained
    • How (and why) our marketing team uses PostHog
    • How (and why) to track your website with PostHog
    • What is SSO and why you should enable it for PostHog
  • Blog
  • Engineering
  • Product updates
  • Launch week

The secrets of PostHog query performance

  • Karl-Aksel Puulmann
    Karl-Aksel Puulmann

We want PostHog to become the first choice for product analytics at any scale. To do that, users should have a smooth experience exploring their product data - including not waiting minutes for queries to load.

In this post, I’m going to break down the why’s and how’s of several major performance improvements we've made in the last few months to achieve that goal.

This article is part of our A Universe of New Features launch week series

How does querying work within PostHog?

The free-form querying experience in PostHog allows you to ask questions about your Trends, Funnels, Retention, and Cohorts with complicated filtering to top it off.

These queries are processed by ClickHouse, where event, user, and group data is stored in a raw format without any preaggregation. ClickHouse excels at analyzing billions of events in seconds even with complex filtering.

However, as awesome as ClickHouse is, nothing is without sharp edges and trade-offs.

Speeding up property filtering by 25x

PostHog allows users to send and analyze an arbitrary number of event and user properties with their data. We store these properties as JSON-encoded string columns in our tables.

One of the first issues we saw after moving to ClickHouse was that, for our largest users, filtering by properties was slow.

Benchmarking these queries using flamegraphs showed that the slowness came from two things: reading JSON properties from disk and (to a lesser extent) parsing it during query-time.

We ended up materializing the most used properties into new columns, leveraging the strength of a columnar database without running into column number limits.

Specifically, the new materialized columns are fast to read from disk as they compress really well and ClickHouse can skip parsing JSON entirely during queries.

On our PostHog Cloud setup, we saw this feature improve query performance by 55% on average, with the p99 improvement being 25x.

Making JOINs 10x faster for large users

Over time, for larger PostHog users with over 10 million visitors, some simple queries like a count of unique users started timing out or running into memory errors.

We narrowed this down to one particular JOIN in our system:

SQL
JOIN (
SELECT distinct_id, argMax(person_id, _timestamp) as person_id
FROM (
SELECT distinct_id, person_id, max(_timestamp) as _timestamp
FROM person_distinct_id
WHERE project_id = 123
GROUP BY person_id, distinct_id, team_id
HAVING max(is_deleted) = 0
)
GROUP BY distinct_id
) AS pdi
-- Table schema
CREATE TABLE person_distinct_id
(
distinct_id VARCHAR,
person_id UUID,
project_id Int64,
_sign Nullable(Int8),
is_deleted Nullable(Int8),
_timestamp DateTime
) ENGINE = CollapsingMergeTree(_sign)

This JOIN is as complicated as it is due to a restriction from ClickHouse: updating data is expensive. In ClickHouse, updates require rewriting whole parts of the table instead of individual rows.

Instead, the recommended approach is to use a ReplacingMergeTree or CollapsingMergeTree table engine and handle updating logic at query-time.

During data ingestion, when a given distinct_id had its person_id changed, PostHog emits a row with is_deleted=1 for the old person_id and a new row with is_deleted=0. The above query would then resolve the distinct_id => person_id mapping at query time.

However, in practice, this query was slow and used up too much memory, due to needing a subquery to aggregate data correctly. It also had subtle issues with using timestamps for versioning, which was problematic when ClickHouse encountered equal timestamps.

After noticing the problem, we realized we didn't need to actually emit rows with is_deleted=0 to behave correctly, and could move to an alternative schema, which can be queried as follows:

SQL
JOIN (
SELECT distinct_id, argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE project_id = 123
GROUP BY distinct_id
HAVING argMax(is_deleted, version) = 0
) AS pdi
-- Table schema
CREATE TABLE person_distinct_id2
(
distinct_id VARCHAR,
person_id UUID,
project_id Int64,
is_deleted Int8,
version Int64 DEFAULT 1,
_timestamp DateTime
) ENGINE = CollapsingMergeTree(version)

For PostHog users with over 10 million visitors, this sped up queries previously bottlenecked on this JOIN by up to 10x.

Sorting events for a 23% win

While debugging other performance issues, one question we kept asking is whether our data is laid out optimally for performance.

PostHog uses a ClickHouse MergeTree table engine to store event data on disk. MergeTree tables can have an ORDER BY clause, which is then used by ClickHouse to store the data in a sorted format on disk and to create a sparse index of the data. The sparse index can then be used to skip reading data during queries.

Our ORDER BY clause originally looked something like this:

SQL
ORDER BY (
project_id,
toDate(timestamp),
cityHash64(distinct_id),
cityHash64(uuid)
)

With that in mind, let’s consider this simplified query counting the number of users who had pageviews within a given time range:

SQL
SELECT count(DISTINCT person_id)
FROM events
WHERE project_id = 2
AND event = '$pageview'
AND timestamp >= '2022-03-01'
AND timestamp < '2022-04-01'

When executing this query, ClickHouse can leverage data being sorted and the sparse index to skip reading most of data from disk. In this case, events from other projects and organizations and events from months other than March.

However, almost all of our most time-sensitive queries in PostHog also filter by event type. After measuring and confirming this, we updated the ORDER BY clause to the following one:

SQL
ORDER BY (
project_id,
toDate(timestamp),
event,
cityHash64(distinct_id),
cityHash64(uuid)
)

This resulted in a roughly 23% query speed up on average. The best trick for performance optimizations is to skip doing unnecessary work.

Migrating data

Changing how data is sorted on disk is not cheap when you have billions on billions of events. For example, on PostHog Cloud, this took five separate attempts and multiple weeks in total to finish. In addition, PostHog has a lot of self-hosted users at various degrees of scale and technical skill who would need to repeat this process.

To tackle this problem, we ended up building a new async migrations system, which safely runs these long-running operations at scale with the press of a button, while handling common edge cases and keeping the platform up and usable.

Self-hosted performance

As mentioned, PostHog can be self-hosted by our users. However, getting it working smoothly across a wide range of deployments at scale keeps our infrastructure team hard at work.

Some features coming in PostHog 1.34.0 (releasing on Thursday) which affect performance for self-hosted users are:

  • Ability to use an external ClickHouse provider. We’ve partnered with Altinity to help support larger installations.
  • Support for ClickHouse sharding and replication in our helm chart. This allows leveraging more machines for faster queries.
  • (Expected in 1.35.0) Upgrading to ClickHouse 21.11: ClickHouse is changing rapidly and each new release is bringing in new performance improvements.

What’s next?

Performance work is never complete and PostHog has a lot of work ahead of us to make answering questions about your product fast, no matter your scale.

Some projects currently in the pipeline are:

  • Removing JOINs for persons (and groups) - ClickHouse is not designed for doing large-scale joins. We’re currently in the middle of refactoring our entire data model for events, persons, and groups to remove the need for JOINs, bypassing the biggest bottleneck most queries share. More information about our plans can be found in this PR.
  • Smart caching time-series queries - PostHog dashboards continually refresh data to show up-to-date graphs. However this results in a lot of repeated work, slowing down queries. By changing semantics around user properties and identifying users, we will be able to start smartly re-using past results when re-calculating queries.
  • Better JSON support in ClickHouse - This feature has been experimentally released in ClickHouse 22.3 and will unlock the benefits of materialized columns with much less complexity.

Interested in chatting about ClickHouse performance or working on similar problems? Send me an email: karl+perf@posthog.com or join our community Slack.


Ready to find out more?

Try PostHog todaySchedule a demo

Author

  • Karl-Aksel Puulmann
    Karl-Aksel Puulmann

Share

Topic(s)

  • Engineering
  • Product updates
  • Launch week

Mar 22, 2022

The best of PostHog.
Delivered twice a month.

Jump to:

  • How does querying work within PostHog?
  • Speeding up property filtering by 25x
  • Making JOINs 10x faster for large users
  • Sorting events for a 23% win
  • Migrating data
  • Self-hosted performance
  • What’s next?
  • Edit this page
  • Raise an issue
  • Toggle content width
  • Toggle dark mode
  • Product

  • Overview
  • Pricing
  • Product analytics
  • Session recording
  • A/B testing
  • Feature flags
  • Apps
  • Customer stories
  • PostHog vs...
  • Docs

  • Quickstart guide
  • Self-hosting
  • Installing PostHog
  • Building an app
  • API
  • Webhooks
  • How PostHog works
  • Data privacy
  • Using PostHog

  • Product manual
  • Apps manuals
  • Tutorials
  • Community

  • Questions?
  • Product roadmap
  • Contributors
  • Partners
  • Newsletter
  • Merch
  • PostHog FM
  • PostHog on GitHub
  • Handbook

  • Getting started
  • Company
  • Strategy
  • How we work
  • Small teams
  • People & Ops
  • Engineering
  • Product
  • Design
  • Marketing
  • Customer success
  • Company

  • About
  • Team
  • Investors
  • Press
  • Blog
  • FAQ
  • Support
  • Careers
© 2022 PostHog, Inc.
  • Code of conduct
  • Privacy policy
  • Terms