index does not get used when there is "OR" in the query I have an index on the check_timestamp column, the index gets used by the following query

... where check_timestamp &lt; NOW() - INTERVAL '30 days' ORDER BY  check_timestamp  NULLS FIRST LIMIT 10


But the index does not get used with the following query

... where (check_timestamp &lt; NOW() - INTERVAL '30 days' OR check_timestamp IS NULL) ORDER BY check_timestamp  NULLS FIRST LIMIT 10


Why is this happening? any way around it?

Below is the database schema

id  uuid [gen_random_uuid()]    
street_db   text    
check_timestamp timestamptz NULL    
last_accessed   timestamptz NULL    
website text    
street  text    
in_use  boolean [false] 
zipcode_db_id   uuid NULL
In general PostgreSQL is capable of using an index in this situation.  It can scan the index two times and combine them with a BitmapOr.

The reason it cannot or has chosen not to do this in your particular case would depend on the particulars of your case, which you are not sharing with us.  Perhaps it just thinks the alternative plan will be cheaper.