Re: q: explain analyze

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark <sendmailtomark(at)yahoo(dot)com>
Cc: Jaime Casanova <systemguards(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: q: explain analyze
Date: 2006-01-10 19:37:20
Message-ID: 2515.1136921840@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mark <sendmailtomark(at)yahoo(dot)com> writes:
> I do have an index on amount, but I guess it won't be used for >= ...

The general rule is that an index is only helpful for extracting a
fairly small subset of the table ("small" can mean as little as 1%).
So a one-sided inequality is not usefully indexable unless the
comparison constant is near the end of the data range. The planner
does understand this and will do the right things as long as the
ANALYZE statistics are reasonably accurate.

> is there any way to force usage of index?

You can try setting enable_seqscan = off, but you'll likely find
that the planner is making the right decision. (If it isn't,
you may want to play with the value of random_page_cost ... but
be wary of changing that based on a small number of test cases.)

> Can I defined index for _NOT_EQUAL_ ?

No. See above.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jaime Casanova 2006-01-10 19:42:45 Re: q: explain analyze
Previous Message Jerry LeVan 2006-01-10 19:24:27 ANN: PgBrowser-1.6 and PgBrowser-1.7