Re: will foreign key improve select query performance

Lists: pgsql-php
From: "petchimuthu lingam" <spmlingam(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: will foreign key improve select query performance
Date: 2008-03-07 04:18:44
Message-ID: cd233fc30803062018o161cb94fua346801b4ac10dc2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-php

If i create foreign key references, whether it will improve the performance
in the select query?

--
With Best Regards,
Petchimuthulingam S


From: Chris <dmagick(at)gmail(dot)com>
To: petchimuthu lingam <spmlingam(at)gmail(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: will foreign key improve select query performance
Date: 2008-03-07 04:26:23
Message-ID: 47D0C3EF.9030501@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-php

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/