pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedForcing postgres NOT to use sequential scan, trough JDBC
4+ messages / 2 participants
[nested] [flat]
* Forcing postgres NOT to use sequential scan, trough JDBC
@ 2009-03-06 10:50 Mario Splivalo <mario.splivalo@megafon.hr>
0 siblings, 2 replies; 4+ messages in thread
From: Mario Splivalo @ 2009-03-06 10:50 UTC (permalink / raw)
To: pgsql-jdbc
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.
Mike
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Forcing postgres NOT to use sequential scan, trough JDBC
@ 2009-03-06 11:40 Dave Cramer <pg@fastcrypt.com>
parent: Mario Splivalo <mario.splivalo@megafon.hr>
1 sibling, 0 replies; 4+ messages in thread
From: Dave Cramer @ 2009-03-06 11:40 UTC (permalink / raw)
To: Mario Splivalo <mario.splivalo@megafon.hr>; +Cc: pgsql-jdbc
I would suggest to you that something else is wrong. In order for postgresql
to use the most efficient method all of the tuning parameters have to be
configured properly. The performance list is a better place to discuss this.
On Fri, Mar 6, 2009 at 5:50 AM, Mario Splivalo <mario.splivalo@megafon.hr>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.
>
> Mike
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Forcing postgres NOT to use sequential scan, trough JDBC
@ 2009-03-09 09:02 Mario Splivalo <mario.splivalo@megafon.hr>
parent: Mario Splivalo <mario.splivalo@megafon.hr>
1 sibling, 1 reply; 4+ messages in thread
From: Mario Splivalo @ 2009-03-09 09:02 UTC (permalink / raw)
To: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Forcing postgres NOT to use sequential scan, trough JDBC
@ 2009-03-09 12:37 Dave Cramer <pg@fastcrypt.com>
parent: Mario Splivalo <mario.splivalo@megafon.hr>
0 siblings, 0 replies; 4+ messages in thread
From: Dave Cramer @ 2009-03-09 12:37 UTC (permalink / raw)
To: Mario Splivalo <mario.splivalo@megafon.hr>; +Cc: pgsql-jdbc
On Mon, Mar 9, 2009 at 5:02 AM, Mario Splivalo <mario.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 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
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2009-03-09 12:37 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-03-06 10:50 Forcing postgres NOT to use sequential scan, trough JDBC Mario Splivalo <mario.splivalo@megafon.hr>
2009-03-06 11:40 ` Dave Cramer <pg@fastcrypt.com>
2009-03-09 09:02 ` Mario Splivalo <mario.splivalo@megafon.hr>
2009-03-09 12:37 ` Dave Cramer <pg@fastcrypt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox