From: Tom Lane <tgl@sss.pgh.pa.us>
To: Claire McLister <mclister@zeesource.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: JDBC/Stored procedure performance issue
Date: Mon, 28 Jan 2008 15:51:53 -0500
Message-ID: <6915.1201553513@sss.pgh.pa.us> (raw)
In-Reply-To: <018573B2-DC52-4B98-9AB6-1ACB953B0035@zeesource.net>
References: <018573B2-DC52-4B98-9AB6-1ACB953B0035@zeesource.net>
Claire McLister <mclister@zeesource.net> writes:
> When I do an EXPLAIN ANALYZE on one query that returns 3261 rows, it
> executes in a reasonable 159ms:
> ...
> If I issue the same query over JDBC or use a PSQL stored procedure, it
> takes over 3000 ms, which, of course is unacceptable!
I suspect that the problem is with "groupid = $1" instead of
"groupid = 57925". The planner is probably avoiding an indexscan
in the parameterized case because it's guessing the actual value will
match so many rows as to make a seqscan faster. Is the distribution
of groupid highly skewed? You might get better results if you increase
the statistics target for that column.
Switching to something newer than 7.4.x might help too. 8.1 and up
support "bitmap" indexscans which work much better for large numbers
of hits, and correspondingly the planner will use one in cases where
it wouldn't use a plain indexscan.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, mclister@zeesource.net
Subject: Re: JDBC/Stored procedure performance issue
In-Reply-To: <6915.1201553513@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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