Inspect statistics the planner uses.

Section: Planner Settings and Statistics

Inspect pg_stats

sql
sql
SELECT schemaname, tablename, attname, n_distinct, most_common_vals
FROM pg_stats
WHERE tablename = 'orders';
Explanation

See summary for usage details.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Planner Settings and Statistics
Show effective_cache_size
Inspect a planner estimate of OS cache availability.
OpenIn sheetsqlsame section
Show random_page_cost
Inspect a cost parameter that influences index-vs-seqscan decisions.
OpenIn sheetsqlsame section
Disable seqscan for investigation
Temporarily discourage sequential scans while investigating plans.
OpenIn sheetsqlsame section
Show work_mem
Inspect a setting that affects sort and hash memory usage.
OpenIn sheetsqlsame section
Set LOCAL work_mem
Increase work_mem for the current transaction only.
OpenIn sheetsqlsame section
EXPLAIN query
Show the planner's chosen execution plan.
OpenIn sheetsql1 tag match