Re: index vs. seq scan choice? - Mailing list pgsql-general

From Tom Lane
Subject Re: index vs. seq scan choice?
Date
Msg-id 27828.1180055291@sss.pgh.pa.us
Whole thread Raw
In response to index vs. seq scan choice?  ("George Pavlov" <gpavlov@mynewplace.com>)
Responses Re: index vs. seq scan choice?
Re: index vs. seq scan choice?
List pgsql-general
"George Pavlov" <gpavlov@mynewplace.com> writes:
> I am curious what could make the PA query to ignore the index. What are
> the specific stats that are being used to make this decision?

The frequency of the specific value being searched for, and the overall
order-correlation of the column.  Since the latter is not dependent on a
particular value, my guess at the reason for the inconsistent results is
that you don't have the column's statistics target set high enough to
track all the interesting values --- or maybe just not high enough to
acquire sufficiently accurate frequency estimates for them.  Take a look
at the pg_stats row for the column ...

(The default statistics target is 10, which is widely considered too
low --- you might find 100 more suitable.)

            regards, tom lane

pgsql-general by date:

Previous
From: "Raymond C. Rodgers"
Date:
Subject: Inheritance question
Next
From: Scott Ribe
Date:
Subject: Uhm, so, yeah, speaking of /.