Skip site navigation (1) Skip section navigation (2)

Re: Indexes for Foreign Keys?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jeff Larsen" <jlar310(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Indexes for Foreign Keys?
Date: 2007-10-29 18:59:03
Message-ID: 14807.1193684343@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-admin
"Jeff Larsen" <jlar310(at)gmail(dot)com> writes:
> I've noticed that PG automatically creates indexes when you create a
> primary key. But when you create a foreign key on a child table, it
> does not create an index on the referencing columns of the child
> table.

This is intentional since depending on what your workload is like,
the index on the child table might be more overhead than it's worth.

If you frequently do updates or deletes on the parent column, you'll
want to have the child column indexed.

			regards, tom lane

In response to

pgsql-admin by date

Next:From: Teodor SigaevDate: 2007-10-29 19:29:35
Subject: Re: Problem with PITR Past Particular WAL File
Previous:From: Medi MontaseriDate: 2007-10-29 18:58:50
Subject: Re: [HACKERS] grep command

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group