Re: wrong rows estimation by hash join - Mailing list pgsql-performance

From Tomas Vondra
Subject Re: wrong rows estimation by hash join
Date
Msg-id 8f79dacb-332e-7bde-e9e9-1a2319aa51f4@enterprisedb.com
Whole thread Raw
In response to wrong rows estimation by hash join  ("James Pang (chaolpan)" <chaolpan@cisco.com>)
List pgsql-performance
Hi,

On 6/9/23 10:36, James Pang (chaolpan) wrote:
>   How does hash join estimation rows ?   pg v14, it make wrong rows
> estimation then leave nest loop lef join that make poor sql plan.  A
> 

I doubt this is specific to hashjoins, we estimate cardinality the same
way for all joins (or more precisely, we estimate it before picking the
particular join method).

I'm just guessing, but I'd bet the join condition is correlated with the
filter on cs_contract:

> ->  Index
> Scan using cs_xxxx_test on cs_contract cc  (cost=0.43..167540.92
> rows=237989 width=115)
> Index Cond: ((xx_to > CURRENT_DATE) AND ((status)::text = ANY
> ('{Active,Inactive,Pending}'::text[])))
> 

If you remove that condition, does the estimate improve?


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-performance by date:

Previous
From: "James Pang (chaolpan)"
Date:
Subject: wrong rows estimation by hash join
Next
From: "James Pang (chaolpan)"
Date:
Subject: Postgresql equal join on function with columns not use index