<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Indexes on Postgres Scripts</title><link>https://www.postgresscripts.com/tags/indexes/</link><description>Recent content in Indexes on Postgres Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>PostgresScripts.com</copyright><lastBuildDate>Sun, 17 Mar 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://www.postgresscripts.com/tags/indexes/index.xml" rel="self" type="application/rss+xml"/><item><title>Identify Large PostgreSQL Indexes for Optimization</title><link>https://www.postgresscripts.com/post/identify-large-indexes-for-postgresql-database-optimization-with-sql/</link><pubDate>Sun, 17 Mar 2024 00:00:00 +0000</pubDate><guid>https://www.postgresscripts.com/post/identify-large-indexes-for-postgresql-database-optimization-with-sql/</guid><description>
&lt;h2 id="find-the-largest-postgresql-indexes-by-size"&gt;Find the Largest PostgreSQL Indexes by Size&lt;/h2&gt;
&lt;p&gt;Which indexes are taking up the most disk in this database? &lt;code&gt;pg_index&lt;/code&gt; joined to &lt;code&gt;pg_class&lt;/code&gt; answers that in one query: every index with its table, schema, tablespace, size, and the command that would recreate it, sorted with the biggest first. It is the inventory step before any decision to drop, rebuild, or move an index.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="7945792173"
data-ad-format="auto"
data-full-width-responsive="true"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;Indexes speed up reads, but each one costs disk space, buffer cache, and write work. PostgreSQL has to maintain every index on a table for each insert, update, and delete, whether or not any query ever uses it. On a database that has grown for years, a few large indexes often account for a big share of total storage, and some of them may no longer serve any query at all. Knowing which indexes are largest is where that review starts.&lt;/p&gt;</description></item></channel></rss>