Re: indexes

From: Tom Allison <tom(at)tacocat(dot)net>
To: Ben <bench(at)silentmedia(dot)com>
Cc: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: indexes
Date: 2006-11-25 17:14:11
Message-ID: 456879E3.4030805@tacocat.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ben wrote:
> Yes, it does. So of course it depends on how you use it to know what's
> going to be more efficient. For instance, if the rows in this table
> contain strings of more than a few bytes, and more than a couple tables
> reference this table with a foreign key, then you will quickly start to
> save space by using a numeric primary key, even if it is an artificial
> construct.
>
> For the kind of work I find myself doing, it's rare that it would be
> more efficient to not have the artificial construct. But that doesn't
> mean one is always better than the other.
>

So let me see if I understand this correctly.

If the real-world primary key is large (say up to 100 characters in length) then
the disadvantage is that you are duplicating this referenced key in several
other tables, each element taking up 100 characters. Space is wasted when
compared to int4 ID's. But not really sure if this is a performance problem for
SELECT except for the space required (varchar(128) vs. int4).

Having two keys, a primary_key of int4 and a unique key of varchar(128) would be
very ugly on INSERT/DELETE/UPDATE queries because of the index overhead.

One table may have rows on the order of 100's.
Another table will be 1,000,000.
The many-to-many join would be.. 100,000,000's
And maybe there I would have need for smaller physical index variable types...

In response to

Responses

  • Re: indexes at 2006-11-25 17:33:35 from Harald Armin Massa
  • Re: indexes at 2006-11-25 19:40:06 from Martijn van Oosterhout

Browse pgsql-general by date

  From Date Subject
Next Message Harald Armin Massa 2006-11-25 17:33:35 Re: indexes
Previous Message Tomi NA 2006-11-25 11:55:29 Re: Development of cross-platform GUI for Open Source DBs