On Sat, May 29, 2021, 4:40 AM Lionel Bouton <lionel.bouton@xxxxxxx> wrote:
The last time I had to use this setting to solve this kind of problem I ended with :
default_statistics_target = 500
But obviously the value suited to your case could be different (I'd increase it until the planner uses the correct index). Note that increasing it increases the costs of maintaining statistics (so you don't want to increase this by several orders of magnitude blindly) but the default value seems fairly conservative to me.
It also increases planning time since those distribution statistics need to be consumed and decisions have to be made.