Skip site navigation (1) Skip section navigation (2)

Re: Delete query takes exorbitant amount of time

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Karim Nassar <karim(dot)nassar(at)NAU(dot)EDU>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>,pgsql-performance(at)postgresql(dot)org
Subject: Re: Delete query takes exorbitant amount of time
Date: 2005-03-25 15:10:48
Message-ID: 1111763448.11750.730.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-performance
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]))
   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


In response to

Responses

pgsql-performance by date

Next:From: Jack XueDate: 2005-03-25 15:12:05
Subject: Script for getting a table of reponse-time breakdown
Previous:From: Tom LaneDate: 2005-03-25 14:41:09
Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group