Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 89FCB6323E8 for ; Sun, 30 Aug 2009 03:32:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 53854-08 for ; Sun, 30 Aug 2009 06:32:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f219.google.com (mail-gx0-f219.google.com [209.85.217.219]) by mail.postgresql.org (Postfix) with ESMTP id 9C9976321EE for ; Sun, 30 Aug 2009 03:32:30 -0300 (ADT) Received: by gxk19 with SMTP id 19so4040128gxk.0 for ; Sat, 29 Aug 2009 23:32:29 -0700 (PDT) Received: by 10.90.129.15 with SMTP id b15mr2706192agd.64.1251613500561; Sat, 29 Aug 2009 23:25:00 -0700 (PDT) Received: from ?192.168.1.11? ([203.123.90.2]) by mx.google.com with ESMTPS id 10sm3478956agd.73.2009.08.29.23.24.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 Aug 2009 23:24:59 -0700 (PDT) Message-ID: <4A9A1B2B.2000600@bretth.com> Date: Sun, 30 Aug 2009 16:24:43 +1000 From: Brett Henderson User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: =?UTF-8?B?0JLRltGC0LDQu9GW0Lkg0KLQuNC80YfQuNGI0LjQvQ==?= CC: Oliver Jowett , pgsql-jdbc@postgresql.org Subject: Re: Prepared Statement Query Planning References: <4A9892E5.4010509@bretth.com> <4A98ED05.6090302@opencloud.com> <4A9921C4.30907@bretth.com> <331e40660908291105m5166f9b8j58bfc2fe6584d57b@mail.gmail.com> In-Reply-To: <331e40660908291105m5166f9b8j58bfc2fe6584d57b@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/87 X-Sequence-Number: 19936 Віталій Тимчишин wrote: > > > 2009/8/29 Brett Henderson > > > 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 " 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