Re: will foreign key improve select query performance

Chris <[email protected]>
Newsgroups gmane.comp.db.postgresql.php
Message-ID <[email protected]>
petchimuthu lingam wrote:
> If i create foreign key references, whether it will improve the 
> performance in the select query?

Foreign keys are used to create integrity in the database, it won't 
affect select performance.

eg:

create table users (
   userid int primary key,
   username text
);

create table news (
   newsid int primary key,
   created_by int references users(userid)
);

That means that a news item cannot be created by a userid that doesn't 
exist.

http://www.postgresql.org/docs/current/interactive/tutorial-fk.html

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
Sent via pgsql-php mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.