pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Table with many NULLS for indexed column yields strange query plan
Date: Sun, 08 Mar 2020 17:31:54 -0400
Message-ID: <10656.1583703114@sss.pgh.pa.us> (raw)
In-Reply-To: <20200308204639.GE22585@hjp.at>
References: <1583456933425-0.post@n3.nabble.com>
	<20200308204639.GE22585@hjp.at>

"Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> How is the selectivity of "type"? Would an index on that column help?

The EXPLAIN results say that the "type = 'Standard'" condition is
completely not selective: in both plans, there is no "Rows Removed by
Filter" indication where it's applied, indicating that it did not
filter out any rows.  Which is odd, because if that isn't removing
any rows, why is the planner overestimating the number of rows
retrieved from table2 by circa 10x?  Maybe a lack of stats for the
"type" column?

I also find it odd that the second plan is uselessly using an index for
table3 (I say "useless" because there's no index condition and no
apparent need for the result to be sorted).  I suspect the OP has been
putting his thumb on the scales in ways he hasn't bothered to tell us
about, like fooling with the cost parameters and/or disabling seqscans.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <10656.1583703114@sss.pgh.pa.us>
Permalink:  ../10656.1583703114@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10656.1583703114@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 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, hjp-pgsql@hjp.at
  Subject: Re: Table with many NULLS for indexed column yields strange query plan
  In-Reply-To: <10656.1583703114@sss.pgh.pa.us>
  References: <1583456933425-0.post@n3.nabble.com> <20200308204639.GE22585@hjp.at> <10656.1583703114@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