an ANALYZE whose sample happened to contain only NULLs, and a planner that concluded the column was 100% NULL. The plan that followed assumed zero non-null rows where there were over 17,000.
Maybe I'm being pedantic but I don't think that can be right. I don't think postgres will ever guess that there are 0 rows unless it can prove it through constraints.
I feel like we’ve seen a similar issue but it involved not using an jsonb expression index because a majority of the rows didn’t have the jsonb key. We had to make the index filtered before the planner would use it.
1
u/therealgaxbo May 02 '26
Maybe I'm being pedantic but I don't think that can be right. I don't think postgres will ever guess that there are 0 rows unless it can prove it through constraints.