Re: index vs. seq scan choice?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "George Pavlov" <gpavlov(at)mynewplace(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: index vs. seq scan choice?
Date: 2007-05-25 01:08:11
Message-ID: 27828.1180055291@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-www

"George Pavlov" <gpavlov(at)mynewplace(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Ribe 2007-05-25 01:15:49 Uhm, so, yeah, speaking of /.
Previous Message Andrew Sullivan 2007-05-25 00:39:11 Re: why postgresql over other RDBMS

Browse pgsql-www by date

  From Date Subject
Next Message Alvaro Herrera 2007-05-25 02:39:22 Re: index vs. seq scan choice?
Previous Message George Pavlov 2007-05-24 23:15:54 index vs. seq scan choice?