Re: Multi-pass planner - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Multi-pass planner
Date
Msg-id 4A8D4CC50200002500029EBD@gw.wicourts.gov
Whole thread Raw
In response to Re: Multi-pass planner  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Greg Stark <gsstark@mit.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


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Multi-pass planner
Next
From: Robert Haas
Date:
Subject: converting between netmask formats