We've tried to use "... WHERE coalesce(...)::bool;" on a test query:

Before:
->  Seq Scan on public.sys_user sys_user_1  (cost=0.00..27140.46 rows=1 width=16) (actual time=0.105..38.627 rows=3289 loops=1)       Filter: (((SubPlan 7) = 0) AND ((SubPlan 8) = 0) AND ((SubPlan 9) = 0))

After:
->  Seq Scan on public.sys_user sys_user_1  (cost=0.00..27140.46 rows=1790 width=16) (actual time=0.136..28.413 rows=3289 loops=1)       Filter: COALESCE((((SubPlan 7) = 0) AND ((SubPlan 8) = 0) AND ((SubPlan 9) = 0)))

The estimate got closer to the actual number of rows.

Regards,
Vitaliy

Reply via email to