Re: BUG #1552: massive performance hit between 7.4 and 8.0.1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: andrew(at)supernews(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org, Keith Browne <tuxedo(at)deepsky(dot)com>, "Brian O'Reilly" <fade(at)deepsky(dot)com>
Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1
Date: 2005-03-23 20:12:43
Message-ID: 13841.1111608763@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-performance

Andrew - Supernews <andrew+nonews(at)supernews(dot)com> writes:
> Changing the order so that the referenced table is fully populated, or at
> least populated with more than a handful of pages of rows, before doing
> _any_ insert on a referencing table in the same session will avoid the
> misplan of the FK trigger queries, because when the first insert happens
> on a referencing table, there will be no reason for the planner to prefer
> a sequential scan. So this result is not surprising at all.

I'm still looking for an example that demonstrates why this is a common
problem that we need to worry about. ISTM that if an FK reference is
hit when there are still zero entries in the referenced table, that
insertion will fail anyway, and so people wouldn't try to load data in
such an order.

In the long term it would be good to replan the FK plans when the
referenced tables have grown so much that the plan ought to change.
Once we have the plan invalidation machinery that Neil is working on,
it might be fairly practical to do that; but no such thing is going
to appear in existing release branches of course.

We could band-aid this in 8.0 as previously suggested (have the planner
assume > 0 pages when it sees actually 0 pages) but without seeing a
concrete example I can't tell if that will fix the complaint or not.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Joel Krajden 2005-03-23 20:22:30 foreign key constraint not working when index tablespace is not default.
Previous Message Roy Badami 2005-03-23 20:04:02 Re: BUG #1518: Conversions to (undocumented) SQL year-month and

Browse pgsql-performance by date

  From Date Subject
Next Message Keith Browne 2005-03-23 20:55:07 Re: BUG #1552: massive performance hit between 7.4 and 8.0.1
Previous Message Andrew - Supernews 2005-03-23 19:46:50 Re: BUG #1552: massive performance hit between 7.4 and 8.0.1