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