Re: Slow query after upgrades - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: Slow query after upgrades
Date
Msg-id 22413.1197588665@sss.pgh.pa.us
Whole thread Raw
In response to Re: Slow query after upgrades  (Oliver Jowett <oliver@opencloud.com>)
Responses Re: Slow query after upgrades  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
Oliver Jowett <oliver@opencloud.com> writes:
> Tom Duffey wrote:
>> This makes a huge difference, thanks.  However, is there anything I can
>> do to help improve the performance of that query when using a newer
>> protocol?

> We need to work out what is going wrong under the newer protocol first,

It looks pretty obvious from the peanut gallery: in the parameterized
query, the planner daren't choose an indexscan, because for the vast
majority of the possible values of the parameter an indexscan would
suck.

Tom's apparently only interested in the case where the parameter is
close to the end of the range, so that only a few rows need to be
retrieved.  In this case the indexscan wins big, but the planner can't
count on that.

A possible hack is to put a reasonably small LIMIT on the query.

            regards, tom lane

pgsql-jdbc by date:

Previous
From: Tom Duffey
Date:
Subject: Re: Slow query after upgrades
Next
From: Oliver Jowett
Date:
Subject: Re: Slow query after upgrades