From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Andres Freund <andres@anarazel.de>
Cc: Emanuel Alvarez <ema@abductedcow.com.ar>
Cc: pgsql-general@postgresql.org
Subject: Re: seq vs index scan in join query
Date: Wed, 29 Nov 2017 21:03:40 +0100
Message-ID: <1511985820.6899.5.camel@cybertec.at> (raw)
In-Reply-To: <20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de>
References: <CAPfMJ90rmEdCXQ0ox9umUMs6=oVfomv9nc9V-bcsdLtZAJgszg@mail.gmail.com>
<1511975838.2309.12.camel@cybertec.at>
<20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de>
Andres Freund wrote:
> On 2017-11-29 18:17:18 +0100, Laurenz Albe wrote:
> > That is because the execution with the sequential scan touched
> > 26492 + 80492 = 106984 blocks, while the second execution touched
> > 311301 + 48510 = 359811 blocks, more than three times as many.
>
> That's not necessarily said. What those count are buffer *accesses*,
> *not* the number of distinct blocks accessed. You'll very commonly have
> more buffer accesses in indexscans but still fewer total reads because a
> lot of those accesses will be reads previously done in the same
> scan. Just imagine a scan of an index with a leaf page pointing to 100
> tuples of the same value - that'd result in at least a 100 buffer
> accesses, but it'd be highly likely that they'll be in cache.
Thanks for explaining that.
Yours,
Laurenz Albe
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: laurenz.albe@cybertec.at, andres@anarazel.de, ema@abductedcow.com.ar
Subject: Re: seq vs index scan in join query
In-Reply-To: <1511985820.6899.5.camel@cybertec.at>
References: <CAPfMJ90rmEdCXQ0ox9umUMs6=oVfomv9nc9V-bcsdLtZAJgszg@mail.gmail.com> <1511975838.2309.12.camel@cybertec.at> <20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de> <1511985820.6899.5.camel@cybertec.at>
* 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