From: Tom Lane <tgl@xxxxxxxxxxxxx> Sent: Thursday, April 15, 2021 17:00 To: Daniel Westermann (DWE) <daniel.westermann@xxxxxxxxxxxxxxxx> Cc: pgsql-performance@xxxxxxxxxxxxxxxxxxxx <pgsql-performance@xxxxxxxxxxxxxxxxxxxx> Subject: Re: Strange behavior once statistics are there >I'd suggest trying to flatten these to be regular joins, ie >try to bring up persons6_ and stufen7_ into the main JOIN nest. >It looks like persons6_.pes_id might be unique, meaning that you >don't really need the IN behavior in the first case so flattening >it should be straightforward. The other one is visibly not unique, >but since you're using "select distinct" at the top level anyway, >getting duplicate rows might not be a problem (unless there are >a lot of duplicates?) Thank you, Tom