Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1552: massive performance hit between 7.4 and 8.0.1
Date
Msg-id 13841.1111608763@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #1552: massive performance hit between 7.4 and 8.0.1  (Andrew - Supernews <andrew+nonews@supernews.com>)
Responses Re: BUG #1552: massive performance hit between 7.4 and 8.0.1
List pgsql-bugs
Andrew - Supernews <andrew+nonews@supernews.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

pgsql-bugs by date:

Previous
From: Roy Badami
Date:
Subject: Re: BUG #1518: Conversions to (undocumented) SQL year-month and
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,