From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vincent van Leeuwen <pgsql.spam@vinz.nl>
Cc: pgsql-performance@postgresql.org
Subject: Re: tweaking costs to favor nestloop
Date: Fri, 13 Jun 2003 10:07:42 -0400
Message-ID: <407.1055513262@sss.pgh.pa.us> (raw)
In-Reply-To: <20030613123922.GX1535@md2.mediadesign.nl>
References: <20030611193313.GE1535@md2.mediadesign.nl>
<23557.1055362673@sss.pgh.pa.us>
<20030613123922.GX1535@md2.mediadesign.nl>
Vincent van Leeuwen <pgsql.spam@vinz.nl> writes:
> How did you calculate the value of 3?
Estimated cost of an indexscan is approximately proportional to
random_page_cost, but cost of a seqscan isn't affected by it.
You had a hash join plan that used two seqscans (so its estimated
cost is unaffected by random_page_cost) plus a merge join plan
that had one indexscan input. I just extrapolated the change in
the indexscan cost needed to make the ratio of total costs agree with
reality. This is a pretty rough calculation of course, but I don't
believe small values of random_page_cost except for situations where all
your data is buffered in RAM. It's real easy to get led down the garden
path by small test cases that get fully buffered (especially when you
repeat them over and over), and pick cost values that will not reflect
reality in a production environment. I can't say whether that actually
happened to you, but it's something to be on your guard about.
> Another problem we've noticed is that on an idle database certain queries are
> better off using an indexscan than a seqscan, something which the planner
> already wanted to do. But when the load on the database gets a lot higher,
> indexscans are consistently slower than seqscans (same query, same
> parameters).
See above. Increasing load reduces the chances that any one query will
find its data already buffered, since there's more competition for the
available buffer space.
> Does 7.4 already have changes in this area that will affect this query?
No.
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-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql.spam@vinz.nl
Subject: Re: tweaking costs to favor nestloop
In-Reply-To: <407.1055513262@sss.pgh.pa.us>
References: <20030611193313.GE1535@md2.mediadesign.nl> <23557.1055362673@sss.pgh.pa.us> <20030613123922.GX1535@md2.mediadesign.nl> <407.1055513262@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