Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yap4b-00074v-9D for pgsql-performance@arkaria.postgresql.org; Wed, 25 Mar 2015 17:26:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yap4a-0006kz-Ns for pgsql-performance@arkaria.postgresql.org; Wed, 25 Mar 2015 17:26:32 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yap4Z-0006iZ-FZ for pgsql-performance@postgresql.org; Wed, 25 Mar 2015 17:26:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yap4W-0003mc-8W for pgsql-performance@postgresql.org; Wed, 25 Mar 2015 17:26:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t2PHQK1F007440; Wed, 25 Mar 2015 13:26:20 -0400 From: Tom Lane To: Feike Steenbergen cc: Tomas Vondra , pgsql-performance@postgresql.org Subject: Re: Index only scan sometimes switches to sequential scan for small amount of rows In-reply-to: References: <5512ADD2.7080402@2ndquadrant.com> Comments: In-reply-to Feike Steenbergen message dated "Wed, 25 Mar 2015 15:22:33 +0100" Date: Wed, 25 Mar 2015 13:26:20 -0400 Message-ID: <7439.1427304380@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Feike Steenbergen writes: > On 25 March 2015 at 13:45, Tomas Vondra 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 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance