Re: Why isn't an index scan being used?

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Abi Noda <a(at)abinoda(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Why isn't an index scan being used?
Date: 2019-02-20 03:00:23
Message-ID: 87ftsji2tb.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

>>>>> "Abi" == Abi Noda <a(at)abinoda(dot)com> writes:

Abi> However, when I index the closed column, a bitmap scan is used
Abi> instead of an index scan, with slightly slower performance. Why
Abi> isn't an index scan being used, given that the exact same number
Abi> of rows are at play as in my query on the state column?

Most likely difference is the correlation estimate for the conditions.
The cost of an index scan includes a factor based on how well correlated
the physical position of rows is with the index order, because this
affects the number of random seeks in the scan. But for nulls this
estimate cannot be performed, and bitmapscan is cheaper than plain
indexscan on poorly correlated data.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Michael Lewis 2019-02-20 04:29:46 Re: Why isn't an index scan being used?
Previous Message Abi Noda 2019-02-20 00:59:20 Re: Why isn't an index scan being used?