pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Roberts <mailing_lists@pandapocket.com>
To: Franck Routier <franck.routier@axege.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Does max size of varchar influence index size
Date: Mon, 30 Jun 2008 13:24:54 -0700
Message-ID: <1214857494.6049.76.camel@localhost> (raw)
In-Reply-To: <1214845078.6710.7.camel@franck-laptop>
References: <1214845078.6710.7.camel@franck-laptop>


On Mon, 2008-06-30 at 18:57 +0200, Franck Routier wrote:
> Hi,
> 
> I have problems with my database becoming huge in size (around 150 GB
> right now, and 2/3 for only three tables, each having around 30 millions
> tuples. Space is spent mainly on indices.).
> 
> I have a lot of multi-column varchar primary keys (natural keys), and
> lot of foreign keys on these tables and thus a lot of indices.
> 
> When using VARCHAR, we defaulted to VARCHAR(32) (because on _some_ of
> the identifiers, we have to apply md5).
> 
> We assumed that using VARCHAR(32) but having values at most 4 characters
> long (for example) wouldn't influence indices size, ie it would be the
> same as using VARCHAR(4) to keep the example.
> 
> Now I really doubt if we were right :)
> 
> So, what should we expect ? And are there other factors influencing
> indices size ?
> 
> Thanks,
> Franck

Is there any particular reason that you're not using a surrogate key?  I
found that switching from natural to surrogate keys in a similar
situation made the indexes not only smaller, but faster.

It really only became an issue after our individual tables got larger
than 20-25G, but I think we got lucky and headed the issue off at the
pass.

I think it should be fairly trivial* to set up a test case using
pg_total_relation_size() to determine whether your suspicions are
correct.

-Mark

* It may not be as trivial as I say, or I'd have done it in the 5
minutes it took to write this email.




view thread (4+ messages)  latest in thread

Message-ID: <1214857494.6049.76.camel@localhost>
Permalink:  ../1214857494.6049.76.camel@localhost/
Also on:    postgresql.org/message-id/1214857494.6049.76.camel@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: mailing_lists@pandapocket.com, franck.routier@axege.com
  Subject: Re: Does max size of varchar influence index size
  In-Reply-To: <1214857494.6049.76.camel@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox