Re: Unnecessary scan from non-overlapping range predicates

2025-06-25 Thread Ajit Awekar
Hi Tom, Thanks a lot for sharing. The GUC constraint_exclusion setting is helpful, especially for handling poorly written queries. Thanks & Best Regards, Ajit On Wed, 25 Jun 2025 at 21:58, Tom Lane wrote: > Ajit Awekar writes: > > EXPLAIN (costs off) > > select * from products where price <

Re: Unnecessary scan from non-overlapping range predicates

2025-06-25 Thread Tom Lane
Ajit Awekar writes: > EXPLAIN (costs off) > select * from products where price < 100 AND price > 300; > Seq Scan on products > Filter: ((price < '100'::numeric) AND (price > '300'::numeric)) > Since this condition is false and result will always be empty. Despite > this, we still perform unnece

Unnecessary scan from non-overlapping range predicates

2025-06-25 Thread Ajit Awekar
Hi Team, Please find below an observation regarding query planning that leads to unnecessary table scan when the WHERE clause contains non-overlapping conditions. EXPLAIN (costs off) select * from products where price < 100 AND price > 300; Seq Scan on products Filter: ((price < '100'::numeri