Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AB79863510B for ; Sat, 29 Aug 2009 15:05:45 -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 71741-06-5 for ; Sat, 29 Aug 2009 18:05:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f206.google.com (mail-bw0-f206.google.com [209.85.218.206]) by mail.postgresql.org (Postfix) with ESMTP id 44DBD635E99 for ; Sat, 29 Aug 2009 15:05:29 -0300 (ADT) Received: by bwz2 with SMTP id 2so2088906bwz.19 for ; Sat, 29 Aug 2009 11:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=RHfd46/sWWWrYBbVnPX4YNfnelspVkKPIogWtrFVcUE=; b=TDF+TJjV5yXflFvQhmofKWx9dFXy+deam/B9iYrweRiWMDrZcYlFPv8Ub8XcdpGMVN eIQY/Stm/Iwk9q0cztyhqWx2lAbO9qdD1O9WrUf7Do4aS+oZZcySh1srGwRu5+x2Q6tS l/hXmK4IN43BGgyZBWjMT5S6sBRajwb/iXsXk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=j0yGQMxml9hZoRlNVPqmq5E3nb/fpPy8juRHWvT5As+8ewk5PxI7CK7+oPj7mEBUnk FZcRKm5PjwjaNJ3qb4wa0iuaeRMk5XmLq70WhyBzpc1An3UA9eVBaMnSLp5oMLkBJ6Zt ggsOULfiifONRzyfxkCUvGrIAJTkUeadtnkU8= MIME-Version: 1.0 Received: by 10.103.122.22 with SMTP id z22mr1080521mum.123.1251569127147; Sat, 29 Aug 2009 11:05:27 -0700 (PDT) In-Reply-To: <4A9921C4.30907@bretth.com> References: <4A9892E5.4010509@bretth.com> <4A98ED05.6090302@opencloud.com> <4A9921C4.30907@bretth.com> Date: Sat, 29 Aug 2009 21:05:27 +0300 Message-ID: <331e40660908291105m5166f9b8j58bfc2fe6584d57b@mail.gmail.com> Subject: Re: Prepared Statement Query Planning From: =?KOI8-U?B?96bUwcymyiD0yc3eydvJzg==?= To: Brett Henderson Cc: Oliver Jowett , pgsql-jdbc@postgresql.org Content-Type: multipart/alternative; boundary=0016e65aed2c3c4b9204724ba502 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.598 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200908/86 X-Sequence-Number: 19935 --0016e65aed2c3c4b9204724ba502 Content-Type: text/plain; charset=ISO-8859-1 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. 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. Best regards, Vitalii Tymchyshyn --0016e65aed2c3c4b9204724ba502 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2009/8/29 Brett Henderson <brett@bretth.com>=
Oliver Jowett wrote:
Brett Henderson wrote:

It looks like you're using setFetchSize(). That forces use of a named s= tatement regardless of prepareThreshold (we have to keep the statement and = corresponding portal alive so we can do subsequent fetches, even if there a= re some other intervening queries, so we can't use the unnamed statemen= t)
Yes, I'm currently using a fetch size of 10000. =A0I can't allow al= l results to be read at once because there can potentially be a huge number= of results in the queries. =A0I'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 par= ameters.
Another options would be either to use protocolLevel=3D2 (writing from memo= ry, may misspell parameter name) - this will force client-side parameter em= bedding or to embed your timestamps into query text by yourself and not to = use PreparedStatement at all. Fortunatelly this are not strings - so no quo= ting needed.

Best regards, Vitalii Tymchyshyn
--0016e65aed2c3c4b9204724ba502--