Re: index-only-scan when there is an index on all columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hadi Moshayedi <hadi(at)citusdata(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: index-only-scan when there is an index on all columns
Date: 2018-02-27 21:08:04
Message-ID: 25619.1519765684@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hadi Moshayedi <hadi(at)citusdata(dot)com> writes:
> I am wondering why is it not using index-only-scan (which would use the
> cache better) and instead it does a bitmap scan?

Never experiment on an empty table and assume that the resulting plan
is the same as you'd get on a large table.

In this case, not only don't you have any meaningful amount of data
loaded, but the planner can see that none of the table's pages are
marked all-visible, meaning that the "index-only" scan would degrade
to a regular indexscan, which is how it gets costed. And on a single-page
table, an indexscan is going to have a hard time beating other
alternatives.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-02-27 21:18:52 Re: index-only-scan when there is an index on all columns
Previous Message Tom Lane 2018-02-27 20:58:14 Re: Unexpected behavior with transition tables in update statement trigger