|
|||||||||||
|
Re: [GENERAL] FK index q'n
From: Tom Lane <tgl(at)sss.pgh.pa.us>
Date: Fri Nov 30 2007 - 10:48:07 EST
The FK relationship as such is only a reason to create an index if you frequently do updates or deletes in table bar. For such operations, the database has to check if there are any matching rows in foo, and an index on foo.bar_id makes that go faster. Now as far as the above-illustrated query goes, no simple index is going to help it, because IS NULL is not an indexable operation. If you are really concerned about queries of that specific form, you could make a partial index create index fooi on foo (id) where bar_id is null; regards, tom lane ---------------------------(end of broadcast)---------------------------TIP 2: Don't 'kill -9' the postmaster Received on Fri Nov 30 10:49:07 2007 This archive was generated by hypermail 2.1.8 : Mon Jun 16 2008 - 21:00:43 EDT |
||||||||||
|
|||||||||||