You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article introduces scalar UDF inlining, a feature under the [Intelligent query processing in SQL databases](../performance/intelligent-query-processing.md) suite of features. This feature improves the performance of queries that invoke scalar UDFs in [!INCLUDE [sssql19](../../includes/sssql19-md.md)] and later versions.
17
17
@@ -37,6 +37,10 @@ The goal of the scalar UDF inlining feature is to improve performance of queries
37
37
38
38
With this new feature, scalar UDFs are automatically transformed into scalar expressions or scalar subqueries that are substituted in the calling query in place of the UDF operator. These expressions and subqueries are then optimized. As a result, the query plan no longer has a user-defined function operator, but its effects are observed in the plan, like views or inline table-valued functions (TVFs).
39
39
40
+
### Automatic inlining of scalar UDFs in Microsoft Fabric Data Warehouse
41
+
42
+
In Microsoft Fabric Data Warehouse, scalar UDFs (currently in preview) are automatically inlined at compile time when the function body and the calling query meet requirements for inlining. For more information, see [CREATE FUNCTION](../../t-sql/statements/create-function-sql-data-warehouse.md?view=fabric&preserve-view=true) and [Scalar UDF inlining](../../relational-databases/user-defined-functions/scalar-udf-inlining.md?view=fabric&preserve-view=true).
43
+
40
44
## Examples
41
45
42
46
The examples in this section use the TPC-H benchmark database. For more information, see the [TPC-H Homepage](https://www.tpc.org/tpch/).
@@ -88,7 +92,7 @@ The query with the UDF performs poorly, due to the reasons outlined previously.
88
92
89
93
| Query: | Query without UDF | Query with UDF (without inlining) | Query with scalar UDF inlining |
These numbers are based on a 10-GB CCI database (using the TPC-H schema), running on a machine with dual processor (12 core), 96-GB RAM, backed by SSD. The numbers include compilation and execution time with a cold procedure cache and buffer pool. The default configuration was used, and no other indexes were created.
94
98
@@ -343,7 +347,7 @@ As described in this article, scalar UDF inlining transforms a query with scalar
343
347
344
348
- If a UDF references built-in functions such as `SCOPE_IDENTITY()`, `@@ROWCOUNT`, or `@@ERROR`, the value returned by the built-in function changes with inlining. This change in behavior is because inlining changes the scope of statements inside the UDF. Starting with [!INCLUDE [sql-server-2019](../../includes/sssql19-md.md)] CU2, inlining is blocked if the UDF references certain intrinsic functions (for example `@@ROWCOUNT`).
345
349
346
-
- If a variable is assigned with the result of an inlined UDF and it also used as `index_column_name` in `FORCESEEK`[Query hints](../../t-sql/queries/hints-transact-sql-query.md), it results in error 8622, indicating that the query processor couldn't produce a query plan because of the hints defined in the query.
350
+
- If a variable is assigned with the result of an inlined UDF and it also used as `index_column_name` in `FORCESEEK`[Query hints (Transact-SQL)](../../t-sql/queries/hints-transact-sql-query.md), it results in error 8622, indicating that the query processor couldn't produce a query plan because of the hints defined in the query.
Returns a **datetime2** value that contains the date and time of the computer on which the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is running. The date and time is returned as UTC time (Coordinated Universal Time). The fractional second precision specification has a range from 1 to 7 digits. The default precision is 7 digits.
29
-
30
+
30
31
> [!NOTE]
31
-
> SYSDATETIME and SYSUTCDATETIME have more fractional seconds precision than GETDATE and GETUTCDATE. SYSDATETIMEOFFSET includes the system time zone offset. SYSDATETIME, SYSUTCDATETIME, and SYSDATETIMEOFFSET can be assigned to a variable of any one of the date and time types.
32
-
33
-
For an overview of all [!INCLUDE[tsql](../../includes/tsql-md.md)] date and time data types and functions, see [Date and Time Data Types and Functions](../../t-sql/functions/date-and-time-data-types-and-functions-transact-sql.md).
34
-
32
+
> `SYSDATETIME` and `SYSUTCDATETIME` have more fractional seconds precision than `GETDATE` and `GETUTCDATE`.
33
+
>
34
+
> `SYSDATETIMEOFFSET` includes the system time zone offset.
35
+
>
36
+
> `SYSDATETIME`, `SYSUTCDATETIME`, and `SYSDATETIMEOFFSET` can be assigned to a variable of any one of the date and time types.
37
+
38
+
For an overview of all [!INCLUDE[tsql](../../includes/tsql-md.md)] date and time data types and functions, see [Date and time data types and functions (Transact-SQL)](date-and-time-data-types-and-functions-transact-sql.md).
[!INCLUDE[tsql](../../includes/tsql-md.md)] statements can refer to SYSUTCDATETIME anywhere they can refer to a **datetime2** expression.
48
-
49
-
SYSUTCDATETIME is a nondeterministic function. Views and expressions that reference this function in a column cannot be indexed.
50
-
51
+
52
+
## Remarks
53
+
54
+
[!INCLUDE[tsql](../../includes/tsql-md.md)] statements can refer to `SYSUTCDATETIME` anywhere they can refer to a **datetime2** expression.
55
+
56
+
`SYSUTCDATETIME` is a nondeterministic function. Views and expressions that reference this function in a column cannot be indexed.
57
+
51
58
> [!NOTE]
52
-
> [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] obtains the date and time values by using the GetSystemTimeAsFileTime() Windows API. The accuracy depends on the computer hardware and version of Windows on which the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is running. The precision of this API is fixed at 100 nanoseconds. The accuracy can be determined by using the GetSystemTimeAdjustment() Windows API.
53
-
54
-
## Examples
59
+
> [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] obtains the date and time values by using the `GetSystemTimeAsFileTime()` Windows API. The accuracy depends on the computer hardware and version of Windows on which the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is running. The precision of this API is fixed at 100 nanoseconds. The accuracy can be determined by using the `GetSystemTimeAdjustment()` Windows API.
60
+
61
+
## Examples
62
+
55
63
The following examples use the six [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] system functions that return current date and time to return the date, time, or both. The values are returned in series; therefore, their fractional seconds might be different.
56
-
57
-
### A. Showing the formats that are returned by the date and time functions
0 commit comments