Re: Index only scan sometimes switches to sequential scan for small amount of rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Feike Steenbergen <feikesteenbergen(at)gmail(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Index only scan sometimes switches to sequential scan for small amount of rows
Date: 2015-03-25 17:26:20
Message-ID: 7439.1427304380@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Feike Steenbergen <feikesteenbergen(at)gmail(dot)com> writes:
> On 25 March 2015 at 13:45, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> wrote:
>>> We can also increase the 'Stats target' for this table, which will
>>> cause the statistics to contain information about 'NOT_YET_PRINTED'
>>> more often, but even then, it may not find any of these records, as
>>> they sometimes do not exist.

>> This is a better solution, IMHO.

> We'll have a go at this, also if what you say about values having to
> appear at least twice, the other values may make it into
> most_common_*, which would make it clearer to us.

In principle increasing the stats target should fix this, whether or not
'NOT_YET_PRINTED' appears in the MCV list after any particular analyze;
because what will happen is that the frequency for 'PRINTED' will more
nearly approach 1, and so the estimated selectivity for other values
will drop even if they're not in the list.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jeff Janes 2015-03-25 18:07:12 Re: Index only scan sometimes switches to sequential scan for small amount of rows
Previous Message Feike Steenbergen 2015-03-25 16:07:13 Re: Index only scan sometimes switches to sequential scan for small amount of rows