Re: the big picture for index-only scans

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: the big picture for index-only scans
Date: 2011-05-11 03:00:50
Message-ID: 201105110300.p4B30pk04429@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Greg Stark wrote:
> >> Putting aside the politics questions, count(*) is an interesting case
> >> -- it exposes some of the unanswered questions about index-only scans.
> >>
> >> The reason "select count(*)" might win would be because we could pick
> >> any index and do an index scan, relying on the visibility map to
> >> optimize away the heap reads. This is only going to be a win if a
> >> large fraction of the heap reads get optimized away.
> >>
> >> It's going to be pretty tricky to determine in the optimizer a) which
> >> index will be cheapest and b) what fraction of index tuples will point
>
> > I assume the smallest non-partial index would be the cheapest index.
>
> That will be true only if you intentionally ignore the points Greg
> raised. If the table isn't entirely ALL_VISIBLE, then the choice of
> index will determine the ordering of the actual table probes that occur.
> There could be more or fewer page reads, in a more or less optimal
> order, depending on the index used.

OK, would the clustering analyze stats (pg_stats.correlation) tell us
that?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Brar Piening 2011-05-11 04:15:08 Re: Windows build issues
Previous Message Pavel Stehule 2011-05-11 02:54:38 Re: VARIANT / ANYTYPE datatype