title: PostgreSQL table size larger than raw data text files
body: <p>I have the following table in my PostgreSQL database:</p>
  
  <pre><code>CREATE TABLE values
  (
      dt        timestamp,
      series_id integer,
      value     real
  );
  CREATE INDEX idx_values_date ON public."values" USING btree (dt);
  ALTER TABLE ONLY public."values" ADD CONSTRAINT values_series_id_fkey FOREIGN KEY (series_id) REFERENCES public.series(id) ON DELETE CASCADE;
  </code></pre>
  
  <p>I'm parsing some CSV files and extracting floats which I add to this table together with a timestamp and series_id which is a foreign key to another table.</p>
  
  <p>The directory containing my raw data files amounts to about 28MB on my drive.
  After feeding the data into my table I do a</p>
  
  <pre><code>SELECT pg_size_pretty( pg_total_relation_size('values') );
  </code></pre>
  
  <p>And find that the table now has ~871503 rows and is now 98MB in size. Is this normal? I was expecting my table to be way less in 
  size than actual text files containing raw data.
  I'd like to mention that the PostgreSQL instance also has PostGIS installed but I'm not using it
  in this particular schema. Furthermore, I'm running PostgreSQL from a docker container.</p>
  
  <p>Later edit ...</p>
  
  <p>After doing some more research and running the following query:</p>
  
  <pre><code>SELECT *, pg_size_pretty(total_bytes) AS total
      , pg_size_pretty(index_bytes) AS INDEX
      , pg_size_pretty(toast_bytes) AS toast
      , pg_size_pretty(table_bytes) AS TABLE
    FROM (
    SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
        SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
                , c.reltuples AS row_estimate
                , pg_total_relation_size(c.oid) AS total_bytes
                , pg_indexes_size(c.oid) AS index_bytes
                , pg_total_relation_size(reltoastrelid) AS toast_bytes
            FROM pg_class c
            LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
            WHERE relkind = 'r'
    ) a
  ) a WHERE a.table_name = 'values';
  </code></pre>
  
  <p>I came up with the following results:</p>
  
  <pre><code>Index: 61MB
  Table: 38MB
  </code></pre>
  
  <p>Can I somehow optimize the index? Maybe it's using some defaults that make it take up so much space?</p>