Query unable to use expression index that coalesces nulls #114078
Labels
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
O-community
Originated from the community
T-sql-queries
SQL Queries Team
X-blathers-triaged
blathers was able to find an owner
Describe the problem
I made a table with a nullable boolean field, and I created an expression index on
coalesce(field, false)
. When I setdisallow_full_table_scans
and query with aWHERE coalesce(field, false)
condition, it tells me that the query contains a full table scan.Weirdly,
WHERE not coalesce(field, false)
runs successfully and uses the expression index.To Reproduce
Here are some commands that repro the problem from scratch:
Now this query fails:
And this query succeeds:
Here are the explains for the two queries:
Expected behavior
The
select * from testing where coalesce(field, false)
query should succeed and use the index.Environment:
I'm running
cockroach start-single-node
on my macbook, and connecting to it withcockroach sql
.Jira issue: CRDB-33326
The text was updated successfully, but these errors were encountered: