Inaccurate (sometimes wildly so) row estimates for simple join

2020-05-22 Thread Greg Nolle
Hi, I’m working on diagnosing an issue with a complex query on a large PG11 database we have. The planner is choosing a plan that takes 60+ seconds but if we force it to use a particular index then it takes only a couple of seconds. I’ve narrowed down what I think is the cause to a very simple joi

Re: Inaccurate (sometimes wildly so) row estimates for simple join

2020-05-22 Thread Greg Nolle
On 22 May 2020 at 15:30:42, Michael Lewis (mle...@entrata.com) wrote: On Fri, May 22, 2020 at 7:27 AM Greg Nolle wrote: > The crux seems to be that test_b does not have an even distribution for > a_id values: it only has records for two of the values in the referenced > table. This i