Re: seq vs index scan in join query

From: Andres Freund <andres(at)anarazel(dot)de>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Emanuel Alvarez <ema(at)abductedcow(dot)com(dot)ar>, pgsql-general(at)postgresql(dot)org
Subject: Re: seq vs index scan in join query
Date: 2017-11-29 17:46:40
Message-ID: 20171129174640.o7q2ge4f3lk25cmo@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rory Campbell-Lange 2017-11-29 19:37:04 Re: large numbers of inserts out of memory strategy
Previous Message Laurenz Albe 2017-11-29 17:17:18 Re: seq vs index scan in join query