On Fri, 2005-03-25 at 01:58 -0500, Tom Lane wrote:
> Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> writes:
> >> In that case there's a datatype mismatch between the referencing and
> >> referenced columns, which prevents the index from being used for the
> >> FK check.
> > Is creating such a foreign key a WARNING yet?
> I believe so as of 8.0. It's a bit tricky since 8.0 does allow some
> cross-type cases to be indexed, but IIRC we have a test that understands
> about that...
src/backend/commands/tablecmds.c, line 3966 in CVSTIP
* Check that the found operator is compatible with the PK index,
* and generate a warning if not, since otherwise costly seqscans
* will be incurred to check FK validity.
if (!op_in_opclass(oprid(o), opclasses[i]))
(errmsg("foreign key constraint \"%s\" "
"will require costly sequential scans",
errdetail("Key columns \"%s\" and \"%s\" "
"are of different types: %s and %s.",
So, yes to the WARNING. Not sure about the cross-type cases...
Karim: Did this happen? If not, can you drop and re-create and confirm
that you get the WARNING? If not, we have problems.
I vote to make this an ERROR in 8.1 - I see little benefit in allowing
this situation to continue. If users do create a FK like this, it just
becomes another performance problem on list...
Best Regards, Simon Riggs
In response to
pgsql-performance by date
|Next:||From: Jack Xue||Date: 2005-03-25 15:12:05|
|Subject: Script for getting a table of reponse-time breakdown|
|Previous:||From: Tom Lane||Date: 2005-03-25 14:41:09|
|Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 |