Skip site navigation (1) Skip section navigation (2)

unique constraints on foreign keys

From: Jaime Casanova <systemguards(at)yahoo(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: unique constraints on foreign keys
Date: 2004-09-20 20:41:51
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-adminpgsql-general
Hi all, 

I have a reference table that holds all the status
used in a system (it's a very little table just 10 or
15 rows). 

create table status (
 cod_status     char(2)     not null primary key,
 nam_status     text        not null

create table some_other_table (
 ... definition of the table ...
 status         char(2) not null references status

ok. This is the idea if a want to do a reference to
the status table i need to create a primary key or a
unique index on the status table.

Obviously the planner will choose always a seq scan in
such a table (it's obvious to you, it's obvious to me,
but not to the planner), but the planner will
calculate the cost of use the index and will choose
the seq. 
So, there is a way to teach the planner always do a
seq on that table and do not ask for use the index?
There is a way to not enforce the creation of a
primary or unique index on a referenced table?

(I mean, a way that not involves the use of a "set"
instruction because the odbc not allow such

Thanx in advance,
Jaime Casanova

Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en

In response to


pgsql-admin by date

Next:From: Stephan SzaboDate: 2004-09-20 21:02:22
Subject: Re: unique constraints on foreign keys
Previous:From: Boris TomicDate: 2004-09-20 17:03:44
Subject: postgres and freebsd

pgsql-general by date

Next:From: Jeff AmielDate: 2004-09-20 20:41:56
Subject: Re: using database for queuing operations?
Previous:From: Jim C. NasbyDate: 2004-09-20 20:39:57
Subject: Re: using database for queuing operations?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group