Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a9jgk-0004IH-Ci for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Dec 2015 01:18:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a9jgj-00036h-6x for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Dec 2015 01:18:29 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a9jg6-0002QO-Qu for pgsql-bugs@postgresql.org; Fri, 18 Dec 2015 01:17:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a9jfy-0008WJ-W6 for pgsql-bugs@postgresql.org; Fri, 18 Dec 2015 01:17:49 +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 tBI1Hf37013865; Thu, 17 Dec 2015 20:17:41 -0500 From: Tom Lane To: grzegorz@thulium.pl cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13824: EXISTS sometimes uses seq scan instead of index In-reply-to: <20151217134502.9563.4560@wrigleys.postgresql.org> References: <20151217134502.9563.4560@wrigleys.postgresql.org> Comments: In-reply-to grzegorz@thulium.pl message dated "Thu, 17 Dec 2015 13:45:02 +0000" Date: Thu, 17 Dec 2015 20:17:41 -0500 Message-ID: <13864.1450401461@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-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org grzegorz@thulium.pl writes: > Whenever I perform select like below, planner thinks it's going to look up > many rows and falls back to seq scan. If I disable seq scan, it correctly > uses the index. You might need to reduce random_page_cost to reflect your environment better ... especially if you're most concerned about performance with all data already cached in memory, which is what these examples are probably showing. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs