Re: index-only-scan when there is an index on all columns - Mailing list pgsql-general

From Tom Lane
Subject Re: index-only-scan when there is an index on all columns
Date
Msg-id 25619.1519765684@sss.pgh.pa.us
Whole thread Raw
In response to index-only-scan when there is an index on all columns  (Hadi Moshayedi <hadi@citusdata.com>)
Responses Re: index-only-scan when there is an index on all columns  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Hadi Moshayedi <hadi@citusdata.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


pgsql-general by date:

Previous
From: Hadi Moshayedi
Date:
Subject: index-only-scan when there is an index on all columns
Next
From: "David G. Johnston"
Date:
Subject: Re: index-only-scan when there is an index on all columns