Re: Multi-pass planner

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Greg Stark" <gsstark(at)mit(dot)edu>
Cc: "decibel" <decibel(at)decibel(dot)org>, "Pg Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Multi-pass planner
Date: 2009-08-20 18:16:53
Message-ID: 4A8D4CC50200002500029EBD@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> wrote:

> Say you're deciding between an index scan and a sequential scan. The
> sequential scan has a total cost of 1000..1000 but the index scan
> has an estimated total cost of 1..10000.

My proposal was to use RMS, which would effectively favor lower worst
case behavior. Specifically, if the estimated cost range is
1000..1000 you get sqrt((1000*1000+1000*1000)/2) = 1000, while
1..10000 yields sqrt((1*1+10000*10000)/2) = 7071.067847. So with this
heuristic it would prefer the sequential scan.

Of course, for these purposes, you would get the same choices by
leaving off the division and square root calculation, so it could
simplify to choosing the lower of 1000*1000+1000*1000 versus
1*1+10000*10000.

-Kevin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-08-20 18:48:52 converting between netmask formats
Previous Message Greg Stark 2009-08-20 17:31:56 Re: Multi-pass planner