• Sources: primary
  • Summary: pg_orca replaced ORCA's Greenplum-calibrated cost model with CCostModelPG, which ports PostgreSQL's costsize.c operator by operator and reads planner settings such as random_page_cost and work_mem at costing time. It has been the default since May 2026. The post explains how it fills gaps between the two planners: ORCA has no startup cost, prices nested loop inners by rebinds where PostgreSQL uses loop counts, and needed early-termination pricing for semi and anti joins, which had made TPC-H Q4-style EXISTS queries come out about 3 times too expensive. A harness runs 311 EXPLAINs through both planners. Where both pick the same top operator, 183 of 188 plans agree within 2%.
  • Why it matters: PostgreSQL tuning settings now steer pg_orca's plan choice the same way they steer the stock planner. When the two planners pick different plans, the cause is the search space or the row estimates, not a different cost scale.
  • Background: ORCA is the Cascades-style cost-based optimizer from Greenplum, described in a SIGMOD 2014 paper. A Cascades optimizer stores equivalent plan alternatives in a memo and uses a cost model to choose among them, so a cost model calibrated for other hardware picks the wrong plans. pg_orca is an MIT-licensed extension for PostgreSQL 18 and 19-devel. It hooks the planner, is opt-in per session or database, and falls back to the standard planner on queries it does not support.