Postgresql – How to get the information of the optimizer of PostgreSQL

optimizationpostgresql

I am curious about the information like

  • total optimization time
  • the time spent on each stage of optimization
  • the number of alternative plans and
  • the cost of each alternative plan.

Best Answer

You can get some of that information by turning on the configuration parameter log_planner_stats. Most of that information, however, doesn't really exist, because the planner does not fully compute all alternative plans and their costs. It only explores an alternative plan until it can determine that it is slower than the current best plan. So alternative plans are not fully materialized.