Re: Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread Sebastian Dressler
> On 9. Jun 2020, at 21:30, Michael Lewis wrote: > >> On Tue, Jun 9, 2020 at 12:34 PM Sebastian Dressler >> wrote: >> - Add an index on top of the whole PK >> - Add indexes onto other columns trying to help the JOIN >> - Add additional statistics on two related columns >> >> Another idea I h

Re: Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread David Rowley
On Wed, 10 Jun 2020 at 09:05, Michael Lewis wrote: >> >> the join selectivity functions have yet to learn about extended statistics. > > > That is very interesting to me. So, extended statistics would help to > properly estimate the result set coming out of a single table when comparing > each o

Re: Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread Michael Lewis
> > the join selectivity functions have yet to learn about extended statistics. > That is very interesting to me. So, extended statistics would help to properly estimate the result set coming out of a single table when comparing each of those columns to one or many values, but not when joining up

Re: Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread David Rowley
On Wed, 10 Jun 2020 at 07:31, Michael Lewis wrote: > > On Tue, Jun 9, 2020 at 12:34 PM Sebastian Dressler > wrote: >> >> - Add an index on top of the whole PK >> - Add indexes onto other columns trying to help the JOIN >> - Add additional statistics on two related columns >> >> Another idea I ha

Re: Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread Michael Lewis
On Tue, Jun 9, 2020 at 12:34 PM Sebastian Dressler wrote: > - Add an index on top of the whole PK > - Add indexes onto other columns trying to help the JOIN > - Add additional statistics on two related columns > > Another idea I had was to make use of generated columns and hash the PKs > together

Planner misestimation for JOIN with VARCHAR

2020-06-09 Thread Sebastian Dressler
Helloes, I do have a set of tables which contain user data and users can choose to have columns as constrained VARCHAR, limit is typically 100. While users can also choose from different types, quite often they go the VARCHAR route. Furthermore, they can pick PKs almost freely. As a result, I q