From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hadi Moshayedi <hadi@citusdata.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: index-only-scan when there is an index on all columns
Date: Tue, 27 Feb 2018 16:08:04 -0500
Message-ID: <25619.1519765684@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+_kT_f6fNS71Z6Dd-hca4-YeLTHgOgKOydE2W0zVwJdr534SA@mail.gmail.com>
References: <CA+_kT_f6fNS71Z6Dd-hca4-YeLTHgOgKOydE2W0zVwJdr534SA@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, hadi@citusdata.com
Subject: Re: index-only-scan when there is an index on all columns
In-Reply-To: <25619.1519765684@sss.pgh.pa.us>
References: <CA+_kT_f6fNS71Z6Dd-hca4-YeLTHgOgKOydE2W0zVwJdr534SA@mail.gmail.com> <25619.1519765684@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox