pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott ribe <scott_ribe@elevated-dev.com>
To: pgsql-admin@postgresql.org, pgsql-general General <pgsql-general@postgresql.org>
Subject: Re: Ideas to deal with table corruption
Date: Sat, 6 Jan 2018 12:14:56 -0700
Message-ID: <D61E7ACB-FF21-4447-8580-AC27E3DD10B2@elevated-dev.com> (raw)
In-Reply-To: <CADBz387cdv6JgKt7PqJa=6Lf7dVepq+DMpi5=m_tijJHS=RNmA@mail.gmail.com>
References: <CAEp6HQXseuvaU_UGOju3rMduhHB+QTYcZa5oda+_82eQ73DVtw@mail.gmail.com>
	<CAH2-WzmpkQo+YaGTDoWQ600HdN5NqJtwA=puDqG0tVa+9PhsWw@mail.gmail.com>
	<CANu8FiyXAZQVCd2uDY1T9acVThFRSTgYZgZFBZaOZtSTuWif2g@mail.gmail.com>
	<CADBz387cdv6JgKt7PqJa=6Lf7dVepq+DMpi5=m_tijJHS=RNmA@mail.gmail.com>

On Jan 6, 2018, at 12:11 PM, Corey Taylor <corey.taylor.fl@gmail.com> wrote:
> Is it possible for an index to not exist on those columns?
> 
> https://www.postgresql.org/docs/current/static/ddl-constraints.html#DDL-CONSTRAINTS-FK
> 
> "A foreign key must reference columns that either are a primary key or form a unique constraint. This means that the referenced columns always have an index (the one underlying the primary key or unique constraint); so checks on whether a referencing row has a match will be efficient."

One should also remember that the foreign key itself should usually be indexed, lest a delete on the referenced table require a table scan on the referencing table.

--
Scott Ribe
https://www.linkedin.com/in/scottribe/
(303) 722-0567





view thread (8+ messages)  latest in thread

Message-ID: <D61E7ACB-FF21-4447-8580-AC27E3DD10B2@elevated-dev.com>
Permalink:  ../D61E7ACB-FF21-4447-8580-AC27E3DD10B2@elevated-dev.com/
Also on:    postgresql.org/message-id/D61E7ACB-FF21-4447-8580-AC27E3DD10B2@elevated-dev.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: scott_ribe@elevated-dev.com, pgsql-general@postgresql.org
  Subject: Re: Ideas to deal with table corruption
  In-Reply-To: <D61E7ACB-FF21-4447-8580-AC27E3DD10B2@elevated-dev.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox