Re: Optimising a two column OR check

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: MichaelDBA <MichaelDBA(at)sqlexec(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Ivan Voras <ivoras(at)gmail(dot)com>, postgres performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Optimising a two column OR check
Date: 2019-10-12 16:58:22
Message-ID: 87imotx5uq.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

>>>>> "MichaelDBA" == MichaelDBA <MichaelDBA(at)sqlexec(dot)com> writes:

MichaelDBA> Yep, you're right, Andrew, adding a couple rows made it do
MichaelDBA> the index only scan.  I reckon I got misled by turning off
MichaelDBA> sequential scans, thinking that actual rows were not
MichaelDBA> important anymore.  Overly simplistic reasonings can get
MichaelDBA> one into trouble, lol.

We do some odd stuff with the statistics estimates for completely empty
tables because (a) it's not common in practice for a table to be always
empty (i.e. the emptiness is usually transient) and (b) if you take the
emptiness of a table at face value, you end up generating insanely bad
plans for certain FK check queries that may not get replanned quickly
enough to mitigate the performance impact.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Ivan Voras 2019-10-13 13:29:19 Re: Optimising a two column OR check
Previous Message MichaelDBA 2019-10-12 15:54:07 Re: Optimising a two column OR check