pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Laurenz Albe <laurenz.albe@cybertec.at>
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 09:46:40 -0800
Message-ID: <20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de> (raw)
In-Reply-To: <1511975838.2309.12.camel@cybertec.at>
References: <CAPfMJ90rmEdCXQ0ox9umUMs6=oVfomv9nc9V-bcsdLtZAJgszg@mail.gmail.com>
	<1511975838.2309.12.camel@cybertec.at>

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.

Greetings,

Andres Freund




view thread (8+ messages)  latest in thread

Message-ID: <20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de>
Permalink:  ../20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de

 · 

reply

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: andres@anarazel.de, laurenz.albe@cybertec.at, ema@abductedcow.com.ar
  Subject: Re: seq vs index scan in join query
  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>

* 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