Misestimate when applying condition like id = id

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Misestimate when applying condition like id = id
Date: 2020-08-20 19:42:03
Message-ID: CAHOFxGouAogS2oRKscsqzd2XVH+10n3w3ihxRngjRd-wC9gvTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Simplified example query-
explain
select * from organizations o where id = id;

On a PG10 instance I get-
Seq Scan on organizations o (cost=0.00..4.21 ***rows=1*** width=37)
Filter: (id = id)

On a PG11 instance with the same or very very similar data, I get-
Seq Scan on organizations o (cost=0.00..5.70 ***rows=270*** width=37)
Filter: (id IS NOT NULL)

Given this is a not null field, it translates to "is true" basically. The
real query that this example was extracted from apparently had a typo in
the join resulting in this bogus id = id condition, but I still curious
about where this estimate change comes from.

*Michael Lewis | Database Engineer*
*Entrata*

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2020-08-20 20:16:35 Re: Misestimate when applying condition like id = id
Previous Message Zahir Lalani 2020-08-20 18:18:46 RE: Window functions speed