Re: regression in analyze

From: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>
To: "Matteo Beccati" <php(at)beccati(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: regression in analyze
Date: 2008-11-07 07:08:34
Message-ID: 3073cc9b0811062308j133ef68dib3987940884e088a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/6/08, Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec> wrote:
> On Thu, Nov 6, 2008 at 9:24 AM, Matteo Beccati <php(at)beccati(dot)com> wrote:
>> Hi,
>>
>>> Attached test shows a regression in analyze command.
>>> Expected rows in an empty table is 2140 even after an ANALYZE is
>>> executed
>>
>> Doesn't seem to be a regression to me, as I've just checked that 8.0 did
>> behave the same. However the question also was raised a few days ago on
>> the italian mailing list and I couldn't find a reasonable explanation
>> for it.
>>
>

this is related to this hack: src/backend/optimizer/util/plancat.c:342

/*
* HACK: if the relation has never yet been vacuumed, use a
* minimum estimate of 10 pages. This emulates a desirable aspect
* of pre-8.0 behavior, which is that we wouldn't assume a newly
* created relation is really small, which saves us from making
* really bad plans during initial data loading. (The plans are
* not wrong when they are made, but if they are cached and used
* again after the table has grown a lot, they are bad.) It would
* be better to force replanning if the table size has changed a
* lot since the plan was made ... but we don't currently have any
* infrastructure for redoing cached plans at all, so we have to
* kluge things here instead.
*
* We approximate "never vacuumed" by "has relpages = 0", which
* means this will also fire on genuinely empty relations. Not
* great, but fortunately that's a seldom-seen case in the real
* world, and it shouldn't degrade the quality of the plan too
* much anyway to err in this direction.
*/
if (curpages < 10 && rel->rd_rel->relpages == 0)
curpages = 10;

commenting that two lines make the estimates correct. now that we have
plan invalidation that hack is still needed?
i know that as the comment suggest this has no serious impact but
certainly this is user visible.

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2008-11-07 07:51:42 Re: Distinct types
Previous Message Jeff Davis 2008-11-07 06:46:28 Re: auto_explain contrib moudle