Re: ERROR: no value found for parameter 1 with JDBC and Explain Analyze

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Virag Saksena" <v_saks(at)hotmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: ERROR: no value found for parameter 1 with JDBC and Explain Analyze
Date: 2005-11-19 00:06:20
Message-ID: 13280.1132358780@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Virag Saksena" <v_saks(at)hotmail(dot)com> writes:
> ERROR: no value found for parameter 1

> Here is sample code which causes this exception ...
> pst=prodconn.prepareStatement("explain analyze select count(*) from
> jam_heaprel r where heap_id = ? and parentaddr = ?");

I don't think EXPLAIN can take parameters (most of the "utility"
statements don't take parameters).

The usual workaround is to use PREPARE:

PREPARE foo(paramtype,paramtype) AS SELECT ...;
EXPLAIN EXECUTE foo(x,y);

This will generate the same parameterized plan as you'd get from the
other way, so it's a reasonable approximation to the behavior with
JDBC parameters.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Kirkwood 2005-11-19 02:27:49 Re: Hardware/OS recommendations for large databases (
Previous Message Luke Lonergan 2005-11-19 00:05:59 Re: Hardware/OS recommendations for large databases (