Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Performance > Re: Creating a ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 4062 of 4352
Post > Topic >>

Re: Creating a foreign key

by lists@[EMAIL PROTECTED] (PFC) May 8, 2008 at 10:02 PM

> When you create a foreign key to a table is there an index that is
> created on the foreign key automatically?

	No, Postgres doesn't do it for you, because if you create (ref_id)  
references table.id, you will perhaps create an index on (ref_id, date)  
which would then fill the purpose (and other purposes), or perhaps your  
table will have 10 rows (but postgres doesnt' know that when you create  
it) and having an index would be useless, or your table could have many  
rows but only a few distinct referenced values, in which case again the  
index would only slow things down.
	PG does not presume to know better than yourself what you're gonna do  
with your data ;)
	UNIQUE and PRIMARY KEY do create UNIQUE INDEXes, of course.

-- 
Sent via pgsql-performance mailing list (pgsql-performance@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
 




 5 Posts in Topic:
Creating a foreign key
lance@[EMAIL PROTECTED]   2008-05-08 11:52:50 
Re: Creating a foreign key
jd@[EMAIL PROTECTED] (&q  2008-05-08 10:00:14 
Re: Creating a foreign key
sthomas@[EMAIL PROTECTED]  2008-05-08 12:18:59 
Re: Creating a foreign key
lance@[EMAIL PROTECTED]   2008-05-08 13:11:49 
Re: Creating a foreign key
lists@[EMAIL PROTECTED]   2008-05-08 22:02:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 14:41:19 CDT 2008.