From: | Jim Finnerty <jfinnert(at)amazon(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why the planner does not use index for a large amount of data? |
Date: | 2017-12-12 03:56:04 |
Message-ID: | 1513050964482-0.post@n3.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs 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
From | Date | Subject | |
---|---|---|---|
Next Message | blaz | 2017-12-12 10:33:12 | Potentially misplaced "we trust" |
Previous Message | Don Seiler | 2017-12-07 17:28:12 | Bug in pg_upgrade standby rsync doc |
From | Date | Subject | |
---|---|---|---|
Next Message | Tsunakawa, Takayuki | 2017-12-12 08:17:31 | RE: Is it possible to sort strings in EBCDIC order in PostgreSQL server? |
Previous Message | Sam Gendler | 2017-12-12 02:23:04 | Re: How to know if a database has changed |