From: Tom Lane <tgl@sss.pgh.pa.us>
To: Oliver Jowett <oliver@opencloud.com>
Cc: Robin Houston <robin.houston@gmail.com>
Cc: PostgreSQL - JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: Cursor-based results: bafflingly slow
Date: Fri, 03 Jul 2009 10:24:35 -0400
Message-ID: <749.1246631075@sss.pgh.pa.us> (raw)
In-Reply-To: <4A4E11EB.4040809@opencloud.com>
References: <1b795e7b0907030546o7e44ebcdteb1168c9d6680380@mail.gmail.com>
<1b795e7b0907030601x53ad69efk5412acc1a2595c61@mail.gmail.com>
<4A4E04D1.5010905@opencloud.com>
<1b795e7b0907030639r562a9006g4c3b286bce3e5d7b@mail.gmail.com>
<4A4E11EB.4040809@opencloud.com>
Oliver Jowett <oliver@opencloud.com> writes:
> If you want to stream results promptly, you may be stuck with removing
> that ORDER BY. I'm not sure if there's any way to say to the planner
> "give me a plan with a low startup cost, even if it has a higher total
> cost" which seems to be what you want here.
You need to use a cursor for that. The problem with the fetchsize
mechanism is that it doesn't give the planner any clue that the user
might not intend to fetch the whole result, or might prefer low startup
cost to low total cost anyway.
> I came across some (very old) posts in the archives that suggested that
> DECLARE CURSOR has a fudge where it ranks plan costs assuming that only
> some rows (10%?) will actually be fetched. I'm not sure if that's true
> of the current planner.
Exactly. As of 8.4 you can control the percentage, too.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, oliver@opencloud.com, robin.houston@gmail.com
Subject: Re: Cursor-based results: bafflingly slow
In-Reply-To: <749.1246631075@sss.pgh.pa.us>
References: <1b795e7b0907030546o7e44ebcdteb1168c9d6680380@mail.gmail.com> <1b795e7b0907030601x53ad69efk5412acc1a2595c61@mail.gmail.com> <4A4E04D1.5010905@opencloud.com> <1b795e7b0907030639r562a9006g4c3b286bce3e5d7b@mail.gmail.com> <4A4E11EB.4040809@opencloud.com> <749.1246631075@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