What is the difference between "x IS NULL" and "NOT (x IS NOT NULL)"? What is the difference between "x IS NULL" and "NOT (x IS NOT NULL)"? postgresql postgresql

What is the difference between "x IS NULL" and "NOT (x IS NOT NULL)"?


Use EXPLAIN to see the difference, if there is any.

I think the query rewriter will optimize this, but I didn't check the source code for this example.

Edit: I was wrong, this is not optimized at all. Where ("users"."deleted_at" IS NULL) can use an index, the (NOT ("users"."deleted_at" IS NOT NULL)) condition results in a sequential disk scan.