From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Lewis <mlewis@entrata.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Israel Brewster <ijbrewster@alaska.edu>
Cc: PostgreSQL Mailing Lists <pgsql-general@postgresql.org>
Subject: Re: Faster distinct query?
Date: Wed, 22 Sep 2021 19:48:39 -0400
Message-ID: <2245342.1632354519@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHOFxGpAHwxiTGSmuDDr8_Nw4LHsKozxSY2aS7Mwg2F1CK6JAw@mail.gmail.com>
References: <0BB059BF-54BD-46FA-8B26-28FEF9A04198@alaska.edu>
<CAHOFxGrvxWFTxNQZNe-cWgf__5ErEZ5JUoFzHNXGGnK9=oqX-A@mail.gmail.com>
<CAKFQuwYWY-2ohhQ_K0Lcr1V1_aT5=Qvk8oeScmMWm54rZKynUg@mail.gmail.com>
<2228441.1632343722@sss.pgh.pa.us>
<CAHOFxGpAHwxiTGSmuDDr8_Nw4LHsKozxSY2aS7Mwg2F1CK6JAw@mail.gmail.com>
Michael Lewis <mlewis@entrata.com> writes:
> On Wed, Sep 22, 2021 at 2:48 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The "index-only" scan is reported to do 86m heap fetches along the
>> way to returning 812m rows, so the data is apparently pretty dirty.
> Do you say that because you would expect many more than 10 tuples per page?
No, I say that because if the table were entirely all-visible, there
would have been *zero* heap fetches. As it stands, it's reasonable
to suspect that a pretty sizable fraction of the index-only scan's
runtime went into random-access heap fetches made to verify
visibility of individual rows.
(You will, of course, never get to exactly zero heap fetches in an
IOS unless the table data is quite static. But one dirty page
out of every ten seems like there were a lot of recent changes.
A VACUUM to clean that up might be well worthwhile.)
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, mlewis@entrata.com, david.g.johnston@gmail.com, ijbrewster@alaska.edu
Subject: Re: Faster distinct query?
In-Reply-To: <2245342.1632354519@sss.pgh.pa.us>
References: <0BB059BF-54BD-46FA-8B26-28FEF9A04198@alaska.edu> <CAHOFxGrvxWFTxNQZNe-cWgf__5ErEZ5JUoFzHNXGGnK9=oqX-A@mail.gmail.com> <CAKFQuwYWY-2ohhQ_K0Lcr1V1_aT5=Qvk8oeScmMWm54rZKynUg@mail.gmail.com> <2228441.1632343722@sss.pgh.pa.us> <CAHOFxGpAHwxiTGSmuDDr8_Nw4LHsKozxSY2aS7Mwg2F1CK6JAw@mail.gmail.com> <2245342.1632354519@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