Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQDOr-00015e-Nc for pgsql-general@arkaria.postgresql.org; Sat, 16 Dec 2017 14:25:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQDOr-0007uB-AQ for pgsql-general@arkaria.postgresql.org; Sat, 16 Dec 2017 14:25:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eQDOr-0007te-32 for pgsql-general@lists.postgresql.org; Sat, 16 Dec 2017 14:25:13 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eQDOn-0007SM-DJ for pgsql-general@lists.postgresql.org; Sat, 16 Dec 2017 14:25:12 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 222A220B60; Sat, 16 Dec 2017 09:25:08 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Sat, 16 Dec 2017 09:25:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=F1fp/5 7jjfnkWKz2/9NG82i+ynSfQZvWZdL6TkFS/I0=; b=b+sGeOizetwFGYR0QqLL4Y R8OYbkVWs4LEIp2Rpl8JljvGECCRzmcLU+tAvjXGF20U6gy2ihTbOdBQ6dRJeIQT CwMHyhav853aUGAt2NLgnQsnqGFQoY6AGUXu/0kue7lAR/SHnik1KvFf8oM3mBrR yETSMkCXDWwU5V56FhOc+XkRI5Iqx0RDnt2QoJPseLpHr4twtm8aN9zmA7UipZlH t0ONfkw3NztwsG3e0Vx8aKsncrZDujteB/Mx/dFV3ErDqCTfNV+dfZ3m6vi0TZiM IThxt0T7jP/MiuL36fJ8N5vCVcU0/l/Q/RYk2T7mdzbNx9u7mHPt0eix42MCJnsQ == X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id D6C0A241E2; Sat, 16 Dec 2017 09:25:07 -0500 (EST) Subject: Re: How to see index was rejected for seq scan? To: Corey Taylor , pgsql-general@lists.postgresql.org References: From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <49e61761-9b33-436e-0568-807f5cf06146@2ndquadrant.com> Date: Sat, 16 Dec 2017 09:25:07 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/16/17 04:03, Corey Taylor wrote: > Essentially, if an index was deemed not to save cost during the input > scan, the planner will schedule a seq scan.  What I'm wondering if there > is anything that indicates a valid index for the scan was found and > rejected (reason doesn't necessarily matter).  I couldn't find anything > in the using explain document, but I have probably missed it.  I would > assume the index would be used to determine if the filter requires a > large scan count. This isn't really possible in the general case, because the planner doesn't actually materialize all possible plans for complex queries, which would be very expensive. But for simple queries, you might get some insight if you set enable_seqscan to off. Then the planner will give you an index-using plan if it is at all possible. Then you can compare the costs. If the planner still gives you a sequential scan, then the index was not applicable for other reasons. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services