Loading topic
pg_stat_statements is a PostgreSQL extension. It keeps running totals for every kind of statement the server executes. It answers questions such as "which queries use the most time?" and "which queries read the most blocks?" It cannot tell you what happened during one particular slow request. This6 min readpg_stat_statements is already enabled in your database. It also assumes a PostgreSQL version of 13 or later, where the timing columns are named `total_ex6 min readpg_stat_statements is already enabled and that you know what calls, total_exec_time, mean_exec_time, and queryid mean. You should be comfortable with ORDER BY, LIMIT, aggregates, and window functions. The column names total_exec_time and mean_exec_time app6 min readpg_stat_statements, can run queries in psql, and know what calls, total_exec_time, and mean_exec_time mean. The column names used here apply to PostgreSQL 13 and later.5 min readpg_stat_statements, can run the total-time and mean-time rankings from earlier chapters, and know that a query plan is a tree of nodes. You should also know that PostgreSQL stores table and index data in 8 kB pages, which it calls blocks.5 min readpg_stat_statements tells you which queries cost the most. It does not tell you why. This chapter covers the handoff: turning a row from the statistics view into a plan you can read and act on.5 min readpg_stat_statements are cumulative. They start at zero when the extension is first loaded or last reset, and they only grow. A ranking by total_exec_time therefore covers everything since that starting point, which might be six months of workload or ten minutes. This chapter cover6 min readpg_stat_statements view and rank queries by total and mean time, as covered in earlier chapters. It also assumes you know what work_mem is. Here you will learn how to find the statements that write temporary files, and what to do about them.6 min readpg_stat_statements columns (calls, total_exec_time, mean_exec_time), that the extension is already enabled, and that you know what a query plan is. It uses the column names from PostgreSQL 13 and later.5 min readpg_stat_statements rows, what other users see instead of query text, and how to give a monitoring role the access it needs. It assumes you have enabled the extension as described earlier in this tutorial. It also assumes you can run SQL as a superuser, or can ask s6 min readpg_stat_statements, can read its core columns, and have ranked queries by total and mean time. It covers three things: what the extension cannot tell you, what happens when its fixed-size table fills up, and what it costs to run. The examples assume PostgreSQL5 min read