## Re: Multi-pass planner

From: "Kevin Grittner" "Robert Haas" , "Greg Stark" "decibel" , "Pg Hackers" Re: Multi-pass planner 2009-08-20 18:16:53 4A8D4CC50200002500029EBD@gw.wicourts.gov (view raw or whole thread) 2009-08-20 15:15:11 from decibel  2009-08-20 16:23:48 from Robert Haas   2009-08-20 16:55:54 from "Kevin Grittner"    2009-08-20 17:10:15 from Robert Haas     2009-08-20 17:28:32 from Greg Stark      2009-08-20 17:31:56 from Greg Stark       2009-08-20 18:16:53 from "Kevin Grittner"       2009-08-20 22:11:16 from Mischa Sandberg      2009-08-21 04:18:52 from Josh Berkus       2009-08-21 17:54:40 from decibel        2013-04-04 01:40:50 from Greg Stark         2013-04-04 15:56:36 from Robert Haas          2013-04-04 18:53:18 from Dimitri Fontaine           2013-04-04 20:28:57 from Robert Haas            2013-04-05 04:43:05 from Amit Kapila           2013-04-19 21:49:20 from Jeff Janes         2013-04-19 21:19:46 from Jeff Janes          2013-04-19 21:24:12 from Claudio Freire           2013-04-19 22:43:27 from Jeff Janes            2013-04-19 22:52:07 from Claudio Freire 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

```

### pgsql-hackers by date

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