Database Error
Cannot generate plan for query because of the following DETERMINISTIC/NOT DETERMINISTIC mismatch: table 'my_table' has a function-based index with a deterministic expression, but it is being used with a non-deterministic subquery
What This Error Means
This error occurs when the database is unable to generate a plan for a query because there is a mismatch between the deterministic and non-deterministic properties of an expression or index. In this case, a function-based index is being used with a subquery that is not deterministic.
Why It Happens
This error typically happens when there is a mismatch between the deterministic and non-deterministic properties of an expression or index, and the database is unable to generate a plan for the query. This can be due to various reasons such as using a function-based index with a non-deterministic subquery, or using a deterministic expression with a non-deterministic function.
How to Fix It
- 1To fix this error, you need to ensure that the deterministic and non-deterministic properties of the expression or index match. You can do this by removing the function-based index, or by rewriting the subquery to be deterministic. Alternatively, you can also consider rewriting the query to avoid using the function-based index altogether.
Example Code Solution
CREATE INDEX idx_my_table_name ON my_table (FUNCTION(my_column));
SELECT * FROM my_table WHERE FUNCTION(my_column) > (SELECT FUNCTION(my_column) FROM my_table);CREATE INDEX idx_my_table_name ON my_table (my_column);
SELECT * FROM my_table WHERE my_column > (SELECT my_column FROM my_table);Fix for Cannot generate plan for query because of the following DETERMINISTIC/NOT DETERMINISTIC mismatch: table 'my_table' has a function-based index with a deterministic expression, but it is being used with a non-deterministic subquery
Browse Related Clusters
Related SQL Errors
Related SQL Blog Articles
Have a different error? Get an instant explanation.
Explain Another Error