Re: Why the planner does not use index for a large amount of data? - Mailing list pgsql-general

From Jim Finnerty
Subject Re: Why the planner does not use index for a large amount of data?
Date
Msg-id 1513050964482-0.post@n3.nabble.com
Whole thread Raw
In response to Why the planner does not use index for a large amount of data?  (hmidi slim <hmidi.slim2@gmail.com>)
List pgsql-general
Hi Hmidi,

    Your description omits some important information, such as whether you
defined your index to include all columns needed by the request, but the
short answer is 'yes', if you retrieve enough rows, then it will be faster
to read the entire heap instead of reading the necessary parts of the index
and all the referenced pages of the heap, in index order.  The decision is
more complex than just this in PostgreSQL due to MVCC, the visibility bits
on each page, and the alternative of doing a bitmap heap scan when the
selectivity is moderate.  The planner is designed to consider all these
factors, cost them, and choose a minimum cost plan.

    If you're convinced that the planner has not picked the fastest plan,
you can either try to force the plan by setting the enable_* guc variables,
or you can use the pg_hint_plan extension (which sets the enable_* variables
on your behalf), to get the plan you want, and then measure the performance
of the query with each alternative.

    /Jim F



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


pgsql-general by date:

Previous
From: Sam Gendler
Date:
Subject: Re: How to know if a database has changed
Next
From: "Tsunakawa, Takayuki"
Date:
Subject: RE: Is it possible to sort strings in EBCDIC order in PostgreSQLserver?