OPTION (ALLOW EXPENSIVE)
- Last UpdatedFeb 07, 2023
- 1 minute read
- PI System
- PI OLEDB Enterprise 2019
- Developer
Unrestricted queries for a number of tables are considered expensive. To protect the system from unintended load, such queries will return an error. For example:
SELECT ea.*
FROM [NuGreen].[Asset].[ElementAttribute] ea
OPTION (FORCE ORDER)
returns the following error:
[NuGreen.Asset.ElementAttribute ea] 'ElementID' column is not restricted. Such a query is considered expensive.
Possible solutions:
-
Add a with or table or, if the is already present, reorder tables in the clause and use the query hint.
-
Add query hint.
Setting the O overwrites the standard behavior and allows the query to run.