Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id EC7036323C1 for ; Mon, 9 Mar 2009 09:37:04 -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 83945-03 for ; Mon, 9 Mar 2009 09:36:55 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.30]) by mail.postgresql.org (Postfix) with ESMTP id A9254632322 for ; Mon, 9 Mar 2009 09:37:02 -0300 (ADT) Received: by yw-out-2324.google.com with SMTP id 5so776182ywh.73 for ; Mon, 09 Mar 2009 05:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=CTyN0UUCXlJ+Jx+BSbh/NkGDHcYJU2IBhelssl7FaR4=; b=LYwBIh08NNHmpkIN4RWTv26aHMJetVYrsHOB4KKh2IYBFq1Odr6LNuguINolkA8ex5 qnumDNoT7d8eewu+gdmysjiDAPZUeXOe9YRhkveKjIg77t3IySgT2mtM3N7UAOVqDypN imygULDw+dkDbisU6L/Tq4dLfxIo9tHugBdmc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=JTM5jqq2AoeNzEPotwIisjzmia2ErTjw8mcLGqBV4AJHIFWP4QA6O2SBaJum10HQfC 05WAS28kJXSIIgLlUSMrw+lS2Tr8KAFae+ZjZEYLOPIsth293pdTYvloZk5Jr93SndlU e4N7HYj9xBUGDGYNpM1jJjUpPdI5SIAqI88c4= MIME-Version: 1.0 Received: by 10.90.119.20 with SMTP id r20mr1098077agc.74.1236602221123; Mon, 09 Mar 2009 05:37:01 -0700 (PDT) In-Reply-To: <49B4DB11.6040008@megafon.hr> References: <49B0FFE4.2030202@megafon.hr> <49B4DB11.6040008@megafon.hr> Date: Mon, 9 Mar 2009 08:37:00 -0400 X-Google-Sender-Auth: f931aa9f608639e9 Message-ID: <491f66a50903090537l181d9995r6841ec3071a74246@mail.gmail.com> Subject: Re: Forcing postgres NOT to use sequential scan, trough JDBC From: Dave Cramer To: Mario Splivalo Cc: pgsql-jdbc@postgresql.org Content-Type: multipart/alternative; boundary=001636164afd1e57e40464aee422 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200903/27 X-Sequence-Number: 19357 --001636164afd1e57e40464aee422 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Mon, Mar 9, 2009 at 5:02 AM, Mario Splivalo wrote: > 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. > > As I said this is not the best way to do this. There is a postgresql list specifically to address these issues; the performance list. The problem with what you are doing is: 1 this affects all queries, and 2 is indicative of not having the database in an optimal state of tune. I strongly suggest you post your problem to the performance list and solve this properly, as this solution will likely cause other problems. Dave > > Mike > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc > --001636164afd1e57e40464aee422 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Mon, Mar 9, 2009 at 5:02 AM, Mario Sp= livalo <m= ario.splivalo@megafon.hr> wrote:
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 o= f 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 ca= ll takes cca 400ms. When I force postgres not to use sequential scan, the f= unction takes around 5-10ms.

I even tried, on the same connection, to issue 'SET enable_seqscan TO f= alse;' trough jdbc before I call my function, but execution time is sti= ll 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 1= 00 persistent connections the load was minimal.

As I said this is not the best way to do this= . There is a postgresql list specifically to address these issues; the perf= ormance list. The problem with what you are doing is: 1=A0 this affects all= queries, and 2 is indicative of not having the database in an optimal stat= e of tune. I strongly suggest you post your problem to the performance list= and solve this properly, as this solution will likely cause other problems= .

Dave

=A0 =A0 =A0 =A0Mike

--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

--001636164afd1e57e40464aee422--