Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 7E03E2E01B7 for ; Fri, 7 Mar 2008 00:35:53 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 25701-02 for ; Fri, 7 Mar 2008 00:35:49 -0400 (AST) X-Greylist: delayed 00:06:54.054188 by SQLgrey-1.7.5 Received: from rn-out-0910.google.com (rn-out-0910.google.com [64.233.170.190]) by postgresql.org (Postfix) with ESMTP id 22DBB2E3118 for ; Fri, 7 Mar 2008 00:35:49 -0400 (AST) Received: by rn-out-0910.google.com with SMTP id e11so427833rng.17 for ; Thu, 06 Mar 2008 20:35:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=v8IHLFJa5JigZJ+5hotxD5AlK9oNpJ25yLlU+PZEbqs=; b=T6x2+UtdFU8PCUa3YOdLGQ0ZW+7dGizIWlNIbxjj0oiMsN5lgkMHL0bU3x5sTFe1U98EeU4Wz1fhjz8VBIkFJtEkj1GHe5hPwwThjee/Y9PkCI+/veIBzneSc0/rqm1jJNkDzzr3M0u7+9aJCmHmReD1n1epSR8/fKs3yL5Km+o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=u4Yv/Zf9k/qk79DjOw3vek2fUtfq8f0QYzsN40ICtec7vM0fUUJfMuxs9/M5uJkJrI3/eaYTW/aavFL7pNoWE0DHURVY1uJmCqYTkyxOrx2/IepaigaW97XubYZ0tV7a0wwsry/+h03KCWSrBFe/upOYDcn+WATy1Um12M9HRyU= Received: by 10.115.108.1 with SMTP id k1mr98043wam.141.1204864134672; Thu, 06 Mar 2008 20:28:54 -0800 (PST) Received: from ?10.1.1.19? ( [203.217.18.65]) by mx.google.com with ESMTPS id y25sm6946274pod.13.2008.03.06.20.28.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 06 Mar 2008 20:28:54 -0800 (PST) Message-ID: <47D0C3EF.9030501@gmail.com> Date: Fri, 07 Mar 2008 15:26:23 +1100 From: Chris User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: petchimuthu lingam CC: pgsql-php@postgresql.org Subject: Re: will foreign key improve select query performance References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/2 X-Sequence-Number: 3827 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/