Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bv7O3-0007Aa-A7 for pgsql-performance@arkaria.postgresql.org; Fri, 14 Oct 2016 18:39:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bv7O2-0006xb-LS for pgsql-performance@arkaria.postgresql.org; Fri, 14 Oct 2016 18:39:18 +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_2) (envelope-from ) id 1bv7MN-00056y-O3 for pgsql-performance@postgresql.org; Fri, 14 Oct 2016 18:37:35 +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_2) (envelope-from ) id 1bv7MH-00025y-B2 for pgsql-performance@postgresql.org; Fri, 14 Oct 2016 18:37:34 +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 u9EIbRfg014826; Fri, 14 Oct 2016 14:37:27 -0400 From: Tom Lane To: Kyle Moser cc: pgsql-performance@postgresql.org Subject: Re: Hibernate generated query slow compared to 'equivalent' hand written one In-reply-to: References: <12358.1476467191@sss.pgh.pa.us> Comments: In-reply-to Kyle Moser message dated "Fri, 14 Oct 2016 14:09:56 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14824.1476470247.1@sss.pgh.pa.us> Date: Fri, 14 Oct 2016 14:37:27 -0400 Message-ID: <14825.1476470247@sss.pgh.pa.us> X-Pg-Spam-Score: -2.3 (--) 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 Kyle Moser writes: > Thanks so much for the response. They are the same data, that was due to > deidentification on my part. So even though the second Hibernate query says > "index only scan" (in addition to the filter, as you said) it is > inefficient. Why does it say index only scan if it can't use the index due > to the types being numeric and the index being bigint? (I suppose my > question here is how to interpret the output properly - so I don't make > this mistake again). The key thing to notice about that is that it says "Filter" not "Index Cond". That means it's pulling data from the index but not making use of the index's search ability --- that is, it's scanning every index entry and applying the "IN" condition to the value, in much the same way as it'd do with heap entries in a plain seqscan. That's a pretty silly plan, which in most cases you would not get if you hadn't forced it. 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