From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Artyom Shaposhnikov <artyom@gmail.com>
To: Michael Lewis <mlewis@entrata.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: increasing effective_cache_size slows down join queries by a factor of 4000x
Date: Thu, 3 Feb 2022 00:34:02 +0100
Message-ID: <d41dcd64-3ce0-4e75-7690-8ea056c5c9f4@enterprisedb.com> (raw)
In-Reply-To: <CA+1Wm9XwEBvdUHWQawmji_Z4wMbCzfvqgmYg0QDMkR5Q_LtikA@mail.gmail.com>
References: <CA+1Wm9U_sP9237f7OH7O=-UTab71DWOO4Qc-vnC78DfsJQBCwQ@mail.gmail.com>
<CAHOFxGqBXyC_OjrNbekaQGKC6=Xo-ac5L-aJxS5QASAsSVRyJg@mail.gmail.com>
<CA+1Wm9XwEBvdUHWQawmji_Z4wMbCzfvqgmYg0QDMkR5Q_LtikA@mail.gmail.com>
On 2/2/22 22:10, Artyom Shaposhnikov wrote:
> the row estimate became ~1000x smaller with the stat in place, so it
> looks like it grossly miscalculates the query plans without the stats
> for large tables representing M:M relations.
>
Well, if the estimates are significantly off (and 3 orders of magnitude
certainly qualifies), then all bets are off. There's no magical option
that'd fix planning in such conditions.
Ultimately, fixing the estimates (e.g. by creating extended statistics)
is the right "fix" as it gives the optimizer the information needed to
pick the right plan.
> On Wed, Feb 2, 2022 at 11:47 AM Michael Lewis <mlewis@entrata.com> wrote:
>>
>> What does the row estimate look like on the scan of data table with that statistic in place? Anytime the stats give a mis-estimate this far off, I wouldn't expect that plans would be optimal except by luck.
>>
>> Index Scan using data_pkey on data t (cost=0.57..21427806.53 rows=58785023 width=131) (actual time=0.024..0.482 rows=854 loops=1)
>> Index Cond: (id > 205284974)
>
It'd be interesting to see the plans without the LIMIT, as that makes
the "actual" values low simply by terminating early.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
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: tomas.vondra@enterprisedb.com, artyom@gmail.com, mlewis@entrata.com
Subject: Re: increasing effective_cache_size slows down join queries by a factor of 4000x
In-Reply-To: <d41dcd64-3ce0-4e75-7690-8ea056c5c9f4@enterprisedb.com>
References: <CA+1Wm9U_sP9237f7OH7O=-UTab71DWOO4Qc-vnC78DfsJQBCwQ@mail.gmail.com> <CAHOFxGqBXyC_OjrNbekaQGKC6=Xo-ac5L-aJxS5QASAsSVRyJg@mail.gmail.com> <CA+1Wm9XwEBvdUHWQawmji_Z4wMbCzfvqgmYg0QDMkR5Q_LtikA@mail.gmail.com> <d41dcd64-3ce0-4e75-7690-8ea056c5c9f4@enterprisedb.com>
* 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