I've had to expand a query to support backwards compatibility with a property that may not exist in older documents, to do this, I've used the IS_DEFINED method to check if the boolean field exists on the object.
I've just noticed that by using this the RU cost goes up 15000%
SELECT T.id FROM Panels T WHERE T.customerId = @CustomerId
COST: ~3 RU
SELECT T.id FROM Panels T WHERE T.customerId = @CustomerId AND (T.archived = false)
COST: ~4 RU
SELECT T.id FROM Panels T WHERE T.customerId = @CustomerId AND (NOT IS_DEFINED(T.archived) OR T.archived = false)
COST: ~450 RU
That is a pretty MASSIVE difference for a boolean field, and really hammering our throughput.
UPDATE: Found a related issue here - DocumentDB Query Requires Unexpected High RUs
Looks like NOT is an issue, so would need some kind of logic like:
SELECT T.id FROM Panels T WHERE T.customerId = @CustomerId AND IIF(IS_DEFINED(T.archived), T.archived, false) = false
But I guess that would still involve a scan?
UPDATE 2:
Tried running the operation without the NOT, and it came in at ~750, but the it had a result set of 1500 id fields.