Further thoughts about warning for costly FK checks

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Further thoughts about warning for costly FK checks
Дата
Msg-id 7266.1079219556@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: Further thoughts about warning for costly FK checks  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
While reviewing Fabien Coelho's patch for emitting warnings for slow
foreign-key checks, it occurred to me that we aren't covering all bases.
The patch as committed makes sure that there is a usable index on the
referenced table, but it does not look for one on the referencing table.
Failure to provide such an index will lead to slow DELETEs on the
referenced table.  And that's a mistake plenty of people make, even
without bringing datatype incompatibilities into it.

I am tempted to add some more code that issues a WARNING about slow
deletes if there's no matching index on the referencing table, or
if that index has type-compatibility problems.  (It turns out that
this is not necessarily the same check as whether the PK index has
compatibility problems.)

The main problem with doing this is that in the common case of doingCREATE TABLE foo (f1 int REFERENCES bar);
there will normally not be any matching index available yet.  Unless
you want a UNIQUE index, which you often wouldn't, there isn't any
way to make the required index during CREATE TABLE; you have to add
it later.  So I'm worried that adding such a warning would create
useless noise during CREATE TABLE.

A possible compromise is to issue warnings only during ALTER TABLE ADD
CONSTRAINT.  I'm not sure how useful that would really be though.

Comments, ideas?
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: jseymour@LinxNet.com (Jim Seymour)
Дата:
Сообщение: 7.4.2 Build broken on (Sparc) Solaris 7 and 8
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Further thoughts about warning for costly FK checks