About when we should setup index?

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: About when we should setup index?
Date: 2006-03-06 20:01:15
Message-ID: 440C950B.3020607@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I have some questions about index.

For example, we have a table
test(id varchar(7) not null primary key,
name varchar(15) ,
sex varchar(1) ,
birth_date date,
valid_in_table boolean not null,
time_stamp timestamp not null default now() );

. id is the primary key, so a default unique index is generated
automatically ?
. if queries based on name are often, index should be setup for name?
if there are 30,000 records, 29,000 records' names are different, will
the index for name still be useful?

. possible values for sex are F/M and null, should we setup index for sex?

. How about index for date and timestamp?

Basically, I'd like to know is there a percentage of the differences
among data to decide whether index will help or not? For example, among
30,000 records, for a column, its value choices are less than A% and
greater than B% so that we know index will help a lot?

thanks a lot!
Emi

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2006-03-06 20:55:28 Re: ERROR: xlog flush request not satisfied
Previous Message Ed L. 2006-03-06 19:47:45 ERROR: xlog flush request not satisfied