Reputation: 8105
If I have a table like so:
Food
-----------------
name | price | x
Let's say I create an index on name & price, but the database has a bunch of null values for both name & price in some of the rows. Does PostgreSQL automatically skip indexing those rows?
Upvotes: 10
Views: 7603
Reputation: 247300
NULL values ARE indexed as well.
You can also use an index to speed up queries with a condition like
WHERE col IS NULL
Something that may come as a surprise to Oracle users is that you can have several rows with a NULL in a unique index. But that makes sense because NULL = NULL
is not true.
Upvotes: 14