Re: Hibernate generated query slow compared to 'equivalent' hand written one

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyle Moser <moser(dot)kyle(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Hibernate generated query slow compared to 'equivalent' hand written one
Date: 2016-10-14 18:37:27
Message-ID: 14825.1476470247@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Kyle Moser <moser(dot)kyle(at)gmail(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Bobby Mozumder 2016-10-18 20:35:20 Should I generate strings in Postgres of Python?
Previous Message Kyle Moser 2016-10-14 18:09:56 Re: Hibernate generated query slow compared to 'equivalent' hand written one