1

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? I heard this behavior might have changed in later releases.

2

Since at least PostgreSQL 8.3, PostgreSQL indexes NULL using a bitmap on the index. That means "yes" it's indexed. Except it takes a bit, rather than a byte[s]. There is no speed advantage insofar as btree indexes are concerned with using a non-NULL value. It will work just as you'd expect.

Dragons here: for more information see this,

Not the answer you're looking for? Browse other questions tagged or ask your own question.