Re: Slow statement when using JDBC

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <yazan(dot)suleiman(at)gmail(dot)com>,<msakrejda(at)truviso(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Slow statement when using JDBC
Date: 2011-02-02 21:49:42
Message-ID: 4D497D16020000250003A249@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Maciek Sakrejda 2011-02-02 21:59:49 Re: Slow statement when using JDBC
Previous Message yazan suleiman 2011-02-02 21:27:25 Re: Slow statement when using JDBC