pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Joseph Shraibman <jks@selectacast.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: exists
Date: Tue, 21 Aug 2001 16:51:00 -0400
Message-ID: <3B82C9B4.4000200@selectacast.net> (raw)
References: <Pine.BSF.4.21.0108211051570.6482-100000@megazone23.bigpanda.com>
<3B82A39A.4060307@selectacast.net>
<10088.998420788@sss.pgh.pa.us>
Then why does the explain say rows=1363 ?
I don't mean to nitpick here, but maybe this is the symptom of a larger problem.
Tom Lane wrote:
> Joseph Shraibman <jks@selectacast.net> writes:
>
>>Well the total cost should be at least as big as the sub-costs, no?
>>
>
> Not if the sub-plan in question is for an EXISTS. The sub-plan cost
> is stated in terms of cost to retrieve all rows --- but the outer level
> EXISTS isn't going to retrieve all rows, it's going to stop as soon as
> it gets even one. So the cost estimate that propagates up is
> 3035.22/1363.
>
> BTW, this sort of consideration is why 7.0 and later state plan costs
> in terms of startup and total cost: if a plan has a nontrivial startup
> cost, just dividing total cost by number of tuples isn't a good way to
> estimate the costs of partial retrieval. Really the cost estimate is
> figured as
> startup_cost + (total_cost-startup_cost) * tuples_retrieved/total_tuples.
> This is important for EXISTS, LIMIT, and maybe a couple other things.
> Without this, we'd not be bright enough to choose fast-startup plans
> over least-total-cost plans in cases where fast-startup is what you want.
>
> regards, tom lane
>
--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio. http://www.targabot.com
view thread (13+ messages) latest in thread
Message-ID: <3B82C9B4.4000200@selectacast.net> Permalink: ../3B82C9B4.4000200@selectacast.net/ Also on: postgresql.org/message-id/3B82C9B4.4000200@selectacast.net ·
reply
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-sql@postgresql.org Cc: jks@selectacast.net, tgl@sss.pgh.pa.us, sszabo@megazone23.bigpanda.com Subject: Re: exists In-Reply-To: <3B82C9B4.4000200@selectacast.net> * 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