pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mike O <mcanix@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Postgres 9.0.4 with Serverside PreparedStatements never returns with large tables
Date: Wed, 12 Feb 2014 10:10:58 +0200
Message-ID: <4D32D385-5CB4-4A04-B25B-85656C0EC492@gmail.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

All,

I've experienced a problem with the following conditions:

PostgreSQL Server 9.0.4 (fine on 9.1.10)
JDBC (Any version)
Serverside prepared statements (prepareThreshold=1)
A very large table (30,000,000+ rows) with indexes on int columns
Java (any version)

The problem is that the serverside prepared statement doesn't return in good time when querying a large table.

<massive_assumption> It seems that the serverside prepared statement tries to do something fancy around the parameterised arguments type inference and casts the arguments as text or varchar which results in the query not returning on time because it's using a seqscan rather than an index scan. </massive_assumption>

If I set the protocolVersion = 2 then it works fine (assuming I pass ints to the setObject or setInt functions)

I've tried the following connection parameters (in different configurations) which didn't work:

prepareThreshold=1
stringType=unspecified
protocolVersion=3

The following connection parameters worked (either/or):

prepareThreshold=0
protocolVersion=2

Can anyone confirm or deny this bug/issue/feature?

I've attached a test class - adjust the query and comment out the properties as you see fit (Obviously the large data set is going to be a problem).

Kind regards,

Mike O'Connell

--

If you don't know where you are going, any road will get you there.

Attachments:

  DBTest.java (application/octet-stream, 3.3K) download

  signature.asc (application/pgp-signature, 454B) download

view thread (2+ messages)  latest in thread

Message-ID: <4D32D385-5CB4-4A04-B25B-85656C0EC492@gmail.com>
Permalink:  ../4D32D385-5CB4-4A04-B25B-85656C0EC492@gmail.com/
Also on:    postgresql.org/message-id/4D32D385-5CB4-4A04-B25B-85656C0EC492@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mcanix@gmail.com
  Subject: Re: Postgres 9.0.4 with Serverside PreparedStatements never returns with large tables
  In-Reply-To: <4D32D385-5CB4-4A04-B25B-85656C0EC492@gmail.com>
  References: <4D32D385-5CB4-4A04-B25B-85656C0EC492@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox