Loading topic
psql, read simple EXPLAIN output, and know why the planner chooses between an index scan and a sequential scan. The previous chapter explained why the planner needs row estimates. This chapter covers the command that produces the numbers behind them.6 min readpg_class. This chapter shows where those numbers come from, how the planner turns them into a row estim7 min readpg_statistic catalog, and the readable view over it is pg_stats. This chapter shows how to read every field in that v6 min readpg_stats, you know what ANALYZE does, and you have seen EXPLAIN output with row estimates. The previous chapter covered the columns of pg_stats one at a time. This chapter covers two of them in depth: most_common_vals with most_common_freqs, and `histogr5 min readEXPLAIN output and have seen pg_stats (covered in earlier chapters). It shows the arithmetic the planner does with those statistics to predict how many rows a plan node returns. Once you know the arithmetic, a bad estimate becomes something you can trace to a ca6 min readpsql, read a simple EXPLAIN plan, and have the orders table from the earlier chapters. You should also know that ANALYZE fills pg_class and pg_stats. Here you learn to find where the planner's row estimates diverge from reality, and which divergences matt6 min readpsql, read pg_stats and pg_class as shown in the earlier chapters, and know that ANALYZE stores the statistics the planner uses. Here you will learn when PostgreSQL runs ANALYZE for you, how to predict that moment, and how to change it for tables that behav7 min readpg_stats, including most common values (MCVs) and histogram bounds, and that you know ANALYZE fills them. Here you will learn how much data ANALYZE reads, what default_statistics_target changes, and what the setting costs.6 min readEXPLAIN (ANALYZE) output and can query pg_stats. It also assumes you know that ANALYZE samples a table and stores most common values (MCVs) and a histogram for each column. Here you will learn what the statistics target controls, how to raise it for a single c6 min readANALYZE, pg_stats, and selectivity estimation. You should be comfortable comparing estimated and actual rows in EXPLAIN ANALYZE.6 min readEXPLAIN output and know what ANALYZE, pg_stats, and autovacuum do. Earlier chapters covered each piece separately. Here you will use them together, in a fixed order, so that a slow query leads you to a specific fix and not to guesswork.6 min readpg_stats and EXPLAIN (ANALYZE) output, and that you know how autovacuum triggers an automatic analyze (autoanalyze) from n_mod_since_analyze and th7 min read