title: Estimating size of Postgres indexes
body: <p>I'm trying to get a better understanding of the tradeoffs involved in creating Postgres indexes. As part of that, I'd love to understand how much space indexes usually use. I've read through <a href="https://www.postgresql.org/docs/12/indexes.html" rel="noreferrer">the docs</a>, but can't find any information on this. I've been doing my own little experiments creating tables and indexes, but it would be amazing if someone could offer an explanation of why the size is what it is. Assume a common table like this with 1M rows, where each row has a unique <code>id</code> and a unique <code>outstanding</code>.</p>
  <pre><code>CREATE TABLE account (
      id integer,
      active boolean NOT NULL,
      outstanding double precision NOT NULL,
  );
  </code></pre>
  <p>and the indexes created by</p>
  <ul>
  <li><code>CREATE INDEX id_idx ON account(id)</code></li>
  <li><code>CREATE INDEX outstanding_idx ON account(outstanding)</code></li>
  <li><code>CREATE INDEX id_outstanding_idx ON account(id, outstanding)</code></li>
  <li><code>CREATE INDEX active_idx ON account(active)</code></li>
  <li><code>CREATE INDEX partial_id_idx ON account(id) WHERE active</code></li>
  </ul>
  <p>What would you estimate the index sizes to be in bytes and more importantly, why?</p>