Re: BUG #1541: Unusually long INSERT times after fresh clean/CREATE TABLES

From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1541: Unusually long INSERT times after fresh clean/CREATE TABLES
Date: 2005-03-18 23:48:34
Message-ID: slrnd3mq6h.31hd.andrew+nonews@trinity.supernews.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2005-03-14, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> The 8.0 planner is intentionally sensitive to the current actual
> physical sizes of tables. It sounds like you've managed to get it to
> plan something on the assumption that the tables are tiny and keep
> using that plan after they aren't tiny any more. The old planner had
> the same kind of issue but it was far easier to hit, so "revert that
> change" isn't an answer that I'm particularly interested in.

On the irc channel we were just investigating a very similar case to this
(which will show up as a bug report here in due course, though not from me).

It turns out that the scenario above is trivial to hit in 8.0 using
referential constraints; RI triggers cache their plans, and on 8.0 the RI
query is planned as a seqscan if the tables are freshly created. (On 7.4
the plan is an index scan, thanks to the default 1000 rows / 10 pages stats.)

What this basically means is that you can't do even a modest size insert
of new data into a fresh schema without having to either trick the planner
(e.g. enable_seqscan=false before the first insert) or defer the addition of
constraints until after the data load (which can be quite inconvenient in
some cases).

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2005-03-19 03:24:22 Re: BUG #1518: Conversions to (undocumented) SQL year-month and
Previous Message Brian O'Reilly 2005-03-18 23:21:02 BUG #1552: massive performance hit between 7.4 and 8.0.1