From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Koen De Groote <kdg.dev@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Index no longer being used, destroying and recreating it restores use.
Date: Thu, 04 Jun 2020 13:08:45 -0400
Message-ID: <1251997.1591290525@sss.pgh.pa.us> (raw)
In-Reply-To: <ac76ccc8-a504-fffd-39b9-67495e918553@aklaver.com>
References: <CAGbX52FL1ihuw9kWB8a2J2QPofgfDhykBENJaoyVEfTTPOvpkw@mail.gmail.com>
<1251078.1591289012@sss.pgh.pa.us>
<ac76ccc8-a504-fffd-39b9-67495e918553@aklaver.com>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 6/4/20 9:43 AM, Tom Lane wrote:
>> It's possible that the index had bloated to the point where the planner
>> thought it was cheaper to use a seqscan. Did you make a note of the
>> cost estimates for the different plans?
> I missed the part where the OP pointed to a SO question. In that
> question where links to explain.depesz.com output.
Ah, I didn't bother to chase that link either.
So the cost estimates are only a fraction of a percent apart, making
it unsurprising for not-so-large changes in the index size to cause
a flip in the apparently-cheapest plan. The real question then is
why the cost estimates aren't actually modeling the real execution
times very well; and I'd venture that that question boils down to
why is this rowcount estimate so far off:
> -> Parallel Seq Scan on oscar mike_three
> (cost=0.000..1934568.500 rows=2385585 width=3141) (actual
> time=159.800..158018.961 rows=23586 loops=3)
> Filter: (four AND (NOT bravo) AND (zulu <=
> 'echo'::timestamp without time zone))
> Rows Removed by Filter: 8610174
We're not going to be able to answer that if the OP doesn't wish
to decloak his data a bit more ... but a reasonable guess is that
those filter conditions are correlated. With late-model Postgres
you might be able to improve matters by creating extended statistics
for this table.
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, adrian.klaver@aklaver.com, kdg.dev@gmail.com
Subject: Re: Index no longer being used, destroying and recreating it restores use.
In-Reply-To: <1251997.1591290525@sss.pgh.pa.us>
References: <CAGbX52FL1ihuw9kWB8a2J2QPofgfDhykBENJaoyVEfTTPOvpkw@mail.gmail.com> <1251078.1591289012@sss.pgh.pa.us> <ac76ccc8-a504-fffd-39b9-67495e918553@aklaver.com> <1251997.1591290525@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