Re: column without pg_stats entry?! - Mailing list pgsql-performance

From Bruno Wolff III
Subject Re: column without pg_stats entry?!
Date
Msg-id 20050121002620.GB16417@wolff.to
Whole thread Raw
In response to column without pg_stats entry?!  (Bernd Heller <bdheller@users.sourceforge.net>)
Responses Re: column without pg_stats entry?!
List pgsql-performance
On Thu, Jan 20, 2005 at 11:14:28 +0100,
  Bernd Heller <bdheller@users.sourceforge.net> wrote:
>
> I wondered why the planner was making such bad assumptions about the
> number of rows to find and had a look at pg_stats. and there was the
> surprise:
> there is no entry in pg_stats for that column at all!! I can only
> suspect that this has to do with the column being all null. I tried to
> change a few records to a not-null value, but re-ANALYZE didn't catch
> them apparently.

Someone else reported this recently and I think it is going to be fixed.

> Is this desired behaviour for analyze? Can I change it somehow? If not,
> is there a better way to accomplish what I'm trying? I'm not to keen on
> disabling seqscan for that query explicitly. It's a simple enough query
> and the planner should be able to find the right plan without help -
> and I'm sure it would if it had stats about it.

In the short run you could add an IS NOT NULL clause to your query.
The optimizer doesn't know that < being TRUE implies IS NOT NULL and
so the partial index won't be used unless you add that clause explicitly.

pgsql-performance by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re:
Next
From: "Bruno Almeida do Lago"
Date:
Subject: Re: PostgreSQL clustering VS MySQL clustering