Re: Delete query takes exorbitant amount of time - Mailing list pgsql-performance

From Simon Riggs
Subject Re: Delete query takes exorbitant amount of time
Date
Msg-id 1111763448.11750.730.camel@localhost.localdomain
Whole thread Raw
In response to Re: Delete query takes exorbitant amount of time  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Delete query takes exorbitant amount of time
Re: Delete query takes exorbitant amount of time
List pgsql-performance
On Fri, 2005-03-25 at 01:58 -0500, Tom Lane wrote:
> Christopher Kings-Lynne <chriskl@familyhealth.com.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]))
   ereport(WARNING,
    (errmsg("foreign key constraint \"%s\" "
        "will require costly sequential scans",
        fkconstraint->constr_name),
     errdetail("Key columns \"%s\" and \"%s\" "
           "are of different types: %s and %s.",
         strVal(list_nth(fkconstraint->fk_attrs, i)),
         strVal(list_nth(fkconstraint->pk_attrs, i)),
           format_type_be(fktypoid[i]),
           format_type_be(pktypoid[i]))));

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


pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1
Next
From: Jack Xue
Date:
Subject: Script for getting a table of reponse-time breakdown