Re: Selectivity of "=" (Re: [HACKERS] Index not used on simple select) - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: Selectivity of "=" (Re: [HACKERS] Index not used on simple select)
Date
Msg-id 379E4B40.A9EF5A06@trust.ee
Whole thread Raw
In response to Selectivity of "=" (Re: [HACKERS] Index not used on simple select)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Selectivity of "=" (Re: [HACKERS] Index not used on simple select)
List pgsql-hackers
Tom Lane wrote:
> It turns out that the selectivity estimate for an "=" comparison is
just
> the attdisbursion statistic calculated by VACUUM ANALYZE, which can be
> roughly defined as the frequency of the most common value in the column.
> (I took statistics too long ago to recall the exact definition.)
> Anyway, given that the test data Ole sent me contains nearly all ''
> entries, I'd say that the 0.995 value is about right for disbursion.
> 
> Indeed, if one were to do a "select * from av_parts where nsn = ''",
> then sequential scan would be the most efficient way to do that.
> The system has no clue that that's not really something you'd do much.

Does the system currently index NULLs as well ?

I suspect supporting partial indexes (initially just non-NULLs) would 
let us have much better and also use indexes intelligently for
mostly-NULL 
columns.

Perhaps a line like 

* Add partial index support

would fit in TODO

-----------------
Hannu


pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: # of Index' Tuples != Heap'
Next
From: Bruce Momjian
Date:
Subject: Re: Selectivity of "=" (Re: [HACKERS] Index not used on simple select)