Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-20 Thread Robert Haas
On Thu, Mar 20, 2014 at 10:45 AM, Tom Lane wrote: > Robert Haas writes: >> So you might think that the problem here is that we're assuming >> uniform density. Let's say there are a million rows in the table, and >> there are 100 that match our criteria, so the first one is going to >> happen 1/1

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-20 Thread Atri Sharma
On Thu, Mar 20, 2014 at 8:51 PM, Tom Lane wrote: > Atri Sharma writes: > > Now, why cannot we take the estimate of all the buckets behind the bucket > > in which our value is present? Will that estimate not give us the > fraction > > of tuples that are expected to be before the first matching ro

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-20 Thread Tom Lane
Atri Sharma writes: > Now, why cannot we take the estimate of all the buckets behind the bucket > in which our value is present? Will that estimate not give us the fraction > of tuples that are expected to be before the first matching row? Uh, no, not unless you assume that the table happens to b

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-20 Thread Atri Sharma
On Thu, Mar 20, 2014 at 8:10 PM, Robert Haas wrote: > On Tue, Mar 18, 2014 at 2:41 PM, Tom Lane wrote: > > Atri Sharma writes: > >> One of the factors that leads to bad estimates is that the histogram of > the > >> values of a column maintained by the planner gets old by time and the > data > >

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-20 Thread Tom Lane
Robert Haas writes: > So you might think that the problem here is that we're assuming > uniform density. Let's say there are a million rows in the table, and > there are 100 that match our criteria, so the first one is going to > happen 1/10,000'th of the way through the table. Thus we set SC =

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-20 Thread Robert Haas
On Tue, Mar 18, 2014 at 2:41 PM, Tom Lane wrote: > Atri Sharma writes: >> One of the factors that leads to bad estimates is that the histogram of the >> values of a column maintained by the planner gets old by time and the data >> in the column changes. So, the histogram is no longer a quite accu

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-18 Thread Tom Lane
Atri Sharma writes: > One of the factors that leads to bad estimates is that the histogram of the > values of a column maintained by the planner gets old by time and the data > in the column changes. So, the histogram is no longer a quite accurate view > of the data and it leads to bad selectivity

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-18 Thread Atri Sharma
On Tue, Mar 18, 2014 at 11:43 PM, Josh Berkus wrote: > > > On Mon, Mar 17, 2014 at 8:47 PM, Tom Lane wrote: > >> Yeah. I would like to see the planner's cost estimates extended to > >> include some sort of uncertainty estimate, whereupon risk-averse people > >> could ask it to prefer low-uncert

Re: [HACKERS] Risk Estimation WAS: Planner hints in Postgresql

2014-03-18 Thread Josh Berkus
> On Mon, Mar 17, 2014 at 8:47 PM, Tom Lane wrote: >> Yeah. I would like to see the planner's cost estimates extended to >> include some sort of uncertainty estimate, whereupon risk-averse people >> could ask it to prefer low-uncertainty plans over high-uncertainty ones >> (the plans we typicall