Re: [ADMIN] Q: Structured index - which one runs faster?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Ernest E Vogelsinger <ernest(at)vogelsinger(dot)at>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: [ADMIN] Q: Structured index - which one runs faster?
Date: 2003-05-22 23:00:54
Message-ID: 20030522155056.R47562-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general pgsql-performance

On Thu, 22 May 2003, Ernest E Vogelsinger wrote:

[response only to -performance]

> sorry for reposting this to the lists, but I feel I posted this at the
> wrong time of day, since now a lot more of you gurus are reading, and I
> really need some knowledgeable input... thanks for consideration :)

It just takes time. :)

> I have a question concerning table/key layout.
>
> I need to store an ID value that consists of three numerical elements:
> - ident1 char(5)
> - ident2 char(5)
> - nodeid int4

This seems like a somewhat odd key layout, why char(5) for the first
two parts if they're numeric as well?

> I need an index on these columns. Insert, delete, and lookup operations
> this in this need to be as fast as possible. Now I have two options:
>
> (a) creating an index on all three columns, or
> (b) create a single varchar column combining all three components into a
> single string, like "ident1:ident2:nodeid" and indexing this column only.
>
> There will be a couple of million rows in this table, the values in
> question are not unique.
>
> Which would be faster in your opinion? (a) or (b)?

Generally, you're probably better off with an index on the three columns.
Otherwise either your clients need to composite the value for the varchar
column or the system does in triggers for insert/update.

Also, what kinds of lookups are you going to be doing? Only lookups based
on all three parts of the key or will you ever be searching based on parts
of the keys?

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ernest E Vogelsinger 2003-05-22 23:36:14 Re: [ADMIN] Q: Structured index - which one runs faster?
Previous Message Tom Lane 2003-05-22 22:53:00 Re: Q: Structured index - which one runs faster?

Browse pgsql-general by date

  From Date Subject
Next Message Darren Ferguson 2003-05-22 23:11:50 Re: ILIKE Problem?
Previous Message John Gray 2003-05-22 22:56:53 Re: Max String length?

Browse pgsql-performance by date

  From Date Subject
Next Message Ernest E Vogelsinger 2003-05-22 23:36:14 Re: [ADMIN] Q: Structured index - which one runs faster?
Previous Message Tom Lane 2003-05-22 22:53:00 Re: Q: Structured index - which one runs faster?