docs/en/operations/optimizing-performance/profile-guided-optimization.md
import SelfManaged from '@site/docs/_snippets/_self_managed_only_no_roadmap.md';
Profile-Guided Optimization (PGO) is a compiler optimization technique where a program is optimized based on the runtime profile.
According to the tests, PGO helps with achieving better performance for ClickHouse. According to the tests, we see improvements up to 15% in QPS on the ClickBench test suite. The more detailed results are available here. The performance benefits depend on your typical workload - you can get better or worse results.
More information about PGO in ClickHouse you can read in the corresponding GitHub issue.
There are two major kinds of PGO: Instrumentation and Sampling (also known as AutoFDO). In this guide is described the Instrumentation PGO with ClickHouse.
-fprofile-generate option to CXXFLAGS.-fprofile-use compiler flags and profiles that are collected from the previous step.A more detailed guide on how to apply PGO is in the Clang documentation.
If you are going to collect a sample workload directly from a production environment, we recommend trying to use Sampling PGO.