From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kyle Moser <moser.kyle@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Hibernate generated query slow compared to 'equivalent' hand written one
Date: Fri, 14 Oct 2016 14:37:27 -0400
Message-ID: <14825.1476470247@sss.pgh.pa.us> (raw)
In-Reply-To: <CAAJSdFFhqHN+qWtMyzWZKo7UsK1qFdRPs0H8bW1cLFW=oLCktg@mail.gmail.com>
References: <CAAJSdFERiMvMdfqp4hHR5gW-XV_vfj8jEk4Bx06RaUkE47LSAw@mail.gmail.com>
<12358.1476467191@sss.pgh.pa.us>
<CAAJSdFFhqHN+qWtMyzWZKo7UsK1qFdRPs0H8bW1cLFW=oLCktg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Kyle Moser <moser.kyle@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, moser.kyle@gmail.com
Subject: Re: Hibernate generated query slow compared to 'equivalent' hand written one
In-Reply-To: <14825.1476470247@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox