Re: Slow statement when using JDBC - Mailing list pgsql-jdbc

From Kevin Grittner
Subject Re: Slow statement when using JDBC
Date
Msg-id 4D497D16020000250003A249@gw.wicourts.gov
Whole thread Raw
In response to Slow statement when using JDBC  (yazan suleiman <yazan.suleiman@gmail.com>)
Responses Re: Slow statement when using JDBC  (Maciek Sakrejda <msakrejda@truviso.com>)
List pgsql-jdbc
yazan suleiman  wrote:

> where magnitude.magnitude>=?

When you pass a literal there, the planner can get a good estimate of
how many rows match that criterion, and give you a good plan based on
that.  When it must prepare a plan with a parameter there, it must
assume that *any* value could be submitted, even one which would
require the entire table to be passed.  The best plan to use will
depend entirely on the actual value, but PostgreSQL currently fixes a
single plan when you prepare a statement on the server.

For queries like this, you want to be sure that the query is planned
each time based on the actual value.

-Kevin

pgsql-jdbc by date:

Previous
From: yazan suleiman
Date:
Subject: Re: Slow statement when using JDBC
Next
From: Maciek Sakrejda
Date:
Subject: Re: Slow statement when using JDBC