Re: A wrong index choose issue because of inaccurate statistics

2020-06-08 Thread Andy Fan
On Mon, Jun 8, 2020 at 10:16 PM Ashutosh Bapat wrote: > I know one project where they used PostgreSQL code base to detect > "robust plans". https://dsl.cds.iisc.ac.in/projects/PICASSO/. Some of > the papers cited in https://www.vldb.org/pvldb/vldb2010/papers/D01.pdf > describe the idea. > In sh

Re: A wrong index choose issue because of inaccurate statistics

2020-06-08 Thread Andy Fan
On Fri, Jun 5, 2020 at 2:30 PM Pavel Stehule wrote: > > > pá 5. 6. 2020 v 8:19 odesílatel David Rowley > napsal: > >> On Mon, 1 Jun 2020 at 01:24, Andy Fan wrote: >> > The one-line fix describe the exact idea in my mind: >> > >> > +++ b/src/backend/optimizer/path/costsize.c >> > @@ -730,6 +730,

Re: A wrong index choose issue because of inaccurate statistics

2020-06-08 Thread Ashutosh Bapat
I know one project where they used PostgreSQL code base to detect "robust plans". https://dsl.cds.iisc.ac.in/projects/PICASSO/. Some of the papers cited in https://www.vldb.org/pvldb/vldb2010/papers/D01.pdf describe the idea. In short, the idea is to annotate a plan with a "bandwidth" i.e. how doe

Re: A wrong index choose issue because of inaccurate statistics

2020-06-04 Thread Pavel Stehule
pá 5. 6. 2020 v 8:19 odesílatel David Rowley napsal: > On Mon, 1 Jun 2020 at 01:24, Andy Fan wrote: > > The one-line fix describe the exact idea in my mind: > > > > +++ b/src/backend/optimizer/path/costsize.c > > @@ -730,6 +730,13 @@ cost_index(IndexPath *path, PlannerInfo *root, > double loop_c

Re: A wrong index choose issue because of inaccurate statistics

2020-06-04 Thread David Rowley
On Mon, 1 Jun 2020 at 01:24, Andy Fan wrote: > The one-line fix describe the exact idea in my mind: > > +++ b/src/backend/optimizer/path/costsize.c > @@ -730,6 +730,13 @@ cost_index(IndexPath *path, PlannerInfo *root, double > loop_count, > > cpu_run_cost += cpu_per_tuple * tuples_fetched

Re: A wrong index choose issue because of inaccurate statistics

2020-06-04 Thread Andy Fan
> > > > Why will the (a, c) be choose? If planner think a = x has only 1 row .. > I just did more research and found above statement is not accurate, the root cause of this situation is because IndexSelectivity = 0. Even through I don't think we can fix anything here since IndexSelectivity is cal

A wrong index choose issue because of inaccurate statistics

2020-05-31 Thread Andy Fan
This thread is a follow-up of thread [1] where I don't have a good writing to describe the issue and solution in my mind. So I start this thread to fix that and also enrich the topic by taking the advices from Ashutosh, Tomas and Tom. Inaccurate statistics is not avoidable and can cause lots of is