Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 138F4634FE7 for ; Mon, 9 Mar 2009 06:03:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 21630-07 for ; Mon, 9 Mar 2009 06:03:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from megafon.hr (megafon.hr [213.202.104.5]) by mail.postgresql.org (Postfix) with ESMTP id 802F2634863 for ; Mon, 9 Mar 2009 06:03:18 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by megafon.hr (Postfix) with ESMTP id 5B77C7EC002 for ; Mon, 9 Mar 2009 10:03:14 +0100 (CET) X-Virus-Scanned: ClamAV at megafon.hr Received: from megafon.hr ([127.0.0.1]) by localhost (localhost.localdomain [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4XxNuovulwTl for ; Mon, 9 Mar 2009 10:03:06 +0100 (CET) Received: from [192.168.1.94] (unknown [212.92.194.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: mike) by megafon.hr (Postfix) with ESMTP id 265EF82400A for ; Mon, 9 Mar 2009 10:02:10 +0100 (CET) Message-ID: <49B4DB11.6040008@megafon.hr> Date: Mon, 09 Mar 2009 10:02:09 +0100 From: Mario Splivalo User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Forcing postgres NOT to use sequential scan, trough JDBC References: <49B0FFE4.2030202@megafon.hr> In-Reply-To: <49B0FFE4.2030202@megafon.hr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/26 X-Sequence-Number: 19356 Mario Splivalo wrote: > How do I tell postgres not to use sequential scan, trough jdbc? > > I tried to include 'SET enable_seqscan TO false;' at the begining of the > plpgsql function, but that seems to work only if I call the function > trough the psql, and only for the subsequent calls in the current > session. I 'know' that postgres is using sequential scan because > function call takes cca 400ms. When I force postgres not to use > sequential scan, the function takes around 5-10ms. > > I even tried, on the same connection, to issue 'SET enable_seqscan TO > false;' trough jdbc before I call my function, but execution time is > still around 400ms. > As it turns out, one can say 'SET senable_seqscan TO false;' at the begining of the plpgsql function. The problem was that I had setup Tomcat so that it keeps only 10 persistent connections. When I set it up to keep 100 persistent connections the load was minimal. Mike