Re: index scan on =, but not < ? - Mailing list pgsql-performance

From David Brown
Subject Re: index scan on =, but not < ?
Date
Msg-id 422F93CE.10400@bigpond.net.au
Whole thread Raw
In response to Re: index scan on =, but not < ?  ("Jim C. Nasby" <decibel@decibel.org>)
Responses Re: index scan on =, but not < ?
List pgsql-performance
Jim C. Nasby wrote:

>Ahh, I was thinking of a high correlation factor on the index. I still
>question 5% though... that seems awefully low.
>
>
Not really. It all depends on how many records you're packing into each
page. 1% may well be the threshold for small records.

Tom mentioned this in the last couple of months. He was citing a uniform
distribution as an example and I thought that sounded a little
pessimistic, but when I did the (possibly faulty) math with a random
distribution, I discovered he wasn't far off.

It's not this simple, but if you can fit 50 randomly organized records
into each page and you want to retrieve 2% of the rows, it's likely
you'll have to fetch every page - believe it or not.

What concerns me is that this all depends on the correlation factor, and
I suspect that the planner is not giving enough weight to this.
Actually, I'm wondering if it's even looking at the statistic, but I
haven't created a test to check. It might explain quite a few complaints
about the planner not utilizing indexes.

pgsql-performance by date:

Previous
From: David Brown
Date:
Subject: Re: index scan on =, but not < ?
Next
From: Jim Johannsen
Date:
Subject: Re: Help trying to tune query that executes 40x slower