Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8snT-0001wZ-5q for pgsql-performance@arkaria.postgresql.org; Fri, 22 Feb 2013 13:36:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U8snR-0001cs-Qv for pgsql-performance@arkaria.postgresql.org; Fri, 22 Feb 2013 13:36:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8smp-00014L-Uw for pgsql-performance@postgresql.org; Fri, 22 Feb 2013 13:35:40 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8smh-00062v-PM for pgsql-performance@postgresql.org; Fri, 22 Feb 2013 13:35:38 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 6F09B28112; Fri, 22 Feb 2013 05:35:28 -0800 (PST) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 6C11140253; Fri, 22 Feb 2013 05:35:28 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id A7507C153D; Fri, 22 Feb 2013 05:35:27 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-2.vmware.com Received: from zcs-prod-ext-mta-2.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-2.vmware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hky_1qK-981X; Fri, 22 Feb 2013 05:35:27 -0800 (PST) Received: from zcs-prod-ext-mta-2.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 713BBC1519; Fri, 22 Feb 2013 05:35:27 -0800 (PST) Received: from [192.168.1.90] (unknown [10.113.62.14]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA; Fri, 22 Feb 2013 05:35:26 -0800 (PST) Message-ID: <5127741D.6090907@vmware.com> Date: Fri, 22 Feb 2013 15:35:25 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Markus Schulz CC: pgsql-performance@postgresql.org Subject: Re: BUG: endless lseek(.., SEEK_END) from select queries on x64 builds References: <201302220925.26460.msc@antzsystem.de> In-Reply-To: <201302220925.26460.msc@antzsystem.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.6 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 22.02.2013 10:25, Markus Schulz wrote: > i can run the query four times with good performance and after that postgresql > starts with the strange lseek() behavior. By default, the JDBC driver re-plans the prepared statement for the first 4 invocations of the query. On the fifth invocation, it switches to using a generic plan, which will be reused on subsequent invocations. See http://jdbc.postgresql.org/documentation/head/server-prepare.html. The generic plan seems to perform much worse in this case. You can disable that mechanism and force re-planning the query every time by setting the "prepareThreshold=0" parameter on the data source. You could check what the generic plan looks like by taking the query used in the java program, with the parameter markers, and running EXPLAIN on that. PostgreSQL version 9.2 might work better in this case. It has some smarts in the server to generate parameter-specific plans even when prepared statements are used, if the planner thinks a specific plan will be faster. - Heikki -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance