For Programmers: Free Programming Magazines  


Home > Archive > PHP with PostgreSQL Database > March 2008 > will foreign key improve select query performance









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author will foreign key improve select query performance
petchimuthu lingam

2008-03-07, 4:46 am

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


--
With Best Regards,
Petchimuthulingam S

Chris

2008-03-07, 4:46 am

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/curr...utorial-fk.html

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

--
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com