pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kenneth Marshall <ktm@rice.edu>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: PostgreSQL 12.3 slow index scan chosen
Date: Fri, 19 Jun 2020 16:59:15 -0400
Message-ID: <1757512.1592600355@sss.pgh.pa.us> (raw)
In-Reply-To: <20200619204950.GL1497@aart.rice.edu>
References: <20200619194914.GI1497@aart.rice.edu>
	<1755412.1592597470@sss.pgh.pa.us>
	<20200619204950.GL1497@aart.rice.edu>

Kenneth Marshall <ktm@rice.edu> writes:
> On Fri, Jun 19, 2020 at 04:11:10PM -0400, Tom Lane wrote:
>> The reason for such an estimation error usually is that the maximum
>> join key values recorded in pg_stats are off: the join side that is
>> going to be exhausted is the one with the smaller max join key.
>> "articles" seems to be small enough that the stats for it will be
>> exact, so your problem is a poor estimate of the max value of
>> objectcustomfieldvalues.objectid.  You might try raising the statistics
>> target for that table.  Or maybe it's just that ANALYZE hasn't been
>> done lately on one table or the other?

> Thank you for the information and suggestion. I tried bumping the statistics for the
> objectcustomfieldvalues.objectid column to 2k, 5k and 10k followed by an analyze and
> the query plan stayed the same. I also analyzed the article table
> repeatedly and their was no change in the plan. The table articles only has 151 rows
> while the objectcustomfieldvalues table has 19031909 rows. Any idea
> about why it is so far off?

What's the actual maximum value of objectcustomfieldvalues.objectid,
and how does that compare to the endpoint value in the pg_stats
histogram for that column?  If you've got one outlier in the table,
it might get missed by ANALYZE.

			regards, tom lane





view thread (15+ messages)  latest in thread

Message-ID: <1757512.1592600355@sss.pgh.pa.us>
Permalink:  ../1757512.1592600355@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1757512.1592600355@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ktm@rice.edu, pgsql-performance@lists.postgresql.org
  Subject: Re: PostgreSQL 12.3 slow index scan chosen
  In-Reply-To: <1757512.1592600355@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