pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brett Henderson <brett@bretth.com>
To: Віталій Тимчишин <tivv00@gmail.com>
Cc: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepared Statement Query Planning
Date: Sun, 30 Aug 2009 16:24:43 +1000
Message-ID: <4A9A1B2B.2000600@bretth.com> (raw)
In-Reply-To: <331e40660908291105m5166f9b8j58bfc2fe6584d57b@mail.gmail.com>
References: <4A9892E5.4010509@bretth.com>
	<4A98ED05.6090302@opencloud.com>
	<4A9921C4.30907@bretth.com>
	<331e40660908291105m5166f9b8j58bfc2fe6584d57b@mail.gmail.com>

Віталій Тимчишин wrote:
>
>
> 2009/8/29 Brett Henderson <brett@bretth.com <mailto:brett@bretth.com>>
>
>     Oliver Jowett wrote:
>
>         Brett Henderson wrote:
>
>         It looks like you're using setFetchSize(). That forces use of
>         a named statement regardless of prepareThreshold (we have to
>         keep the statement and corresponding portal alive so we can do
>         subsequent fetches, even if there are some other intervening
>         queries, so we can't use the unnamed statement)
>
>     Yes, I'm currently using a fetch size of 10000.  I can't allow all
>     results to be read at once because there can potentially be a huge
>     number of results in the queries.  I've just tested it out, and
>     sure enough leaving the fetch size at 0 prevents the use of named
>     statements.
>
>
> How about "create or replace temp view tmp_v as <query>" without 
> setFetchSize and then "select * from tmp_v" with setFetchSize? Not 
> sure still if DDL can use prepared query parameters.
I don't think I can do that.  I couldn't use the syntax
"PREPARE STATEMENT mystatement (timestamp, timestamp) AS CREATE TEMP 
VIEW tmp_nodes AS SELECT id, version FROM nodes WHERE timestamp > ? AND 
timestamp <= ?"
> Another options would be either to use protocolLevel=2 (writing from 
> memory, may misspell parameter name) - this will force client-side 
> parameter embedding or to embed your timestamps into query text by 
> yourself and not to use PreparedStatement at all. Fortunatelly this 
> are not strings - so no quoting needed.
Will this force me to load all results in memory (ie. prevent me from 
reading resultsets in batches)?  I'm hesitant to force the older 
protocol, I've read elsewhere that it should be avoided if possible 
(something about exception handling??).

At this point it sounds like the lesser evil is to to specify some "set 
local enable_seqscan = false" type statements.  It seems to be working 
well enough.

Brett




view thread (9+ messages)

Message-ID: <4A9A1B2B.2000600@bretth.com>
Permalink:  ../4A9A1B2B.2000600@bretth.com/
Also on:    postgresql.org/message-id/4A9A1B2B.2000600@bretth.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: brett@bretth.com, tivv00@gmail.com, oliver@opencloud.com
  Subject: Re: Prepared Statement Query Planning
  In-Reply-To: <4A9A1B2B.2000600@bretth.com>
  References: <4A9892E5.4010509@bretth.com> <4A98ED05.6090302@opencloud.com> <4A9921C4.30907@bretth.com> <331e40660908291105m5166f9b8j58bfc2fe6584d57b@mail.gmail.com> <4A9A1B2B.2000600@bretth.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