whats diffrence between in two query in performance respect
-
hi to all whats diffrence between two below query in performance respect: query 1:
SELECT n, dbo.AddOne(n) AS r
FROM dbo.T1
ORDER BY r;function addOne is this:
CREATE FUNCTION dbo.AddOneInline(@n AS BIGINT) RETURNS TABLE
AS
RETURN SELECT @n + 1 AS val;
GOand query2:
SELECT n, (SELECT val FROM dbo.AddOneInline(n)) AS r
FROM dbo.T1
ORDER BY r;and defination of function is:
GO
CREATE FUNCTION dbo.AddOneInline(@n AS BIGINT) RETURNS TABLE
AS
RETURN SELECT @n + 1 AS val;
GOquery 2 is very good in performance and i want to know whats difference between in this two query
-
hi to all whats diffrence between two below query in performance respect: query 1:
SELECT n, dbo.AddOne(n) AS r
FROM dbo.T1
ORDER BY r;function addOne is this:
CREATE FUNCTION dbo.AddOneInline(@n AS BIGINT) RETURNS TABLE
AS
RETURN SELECT @n + 1 AS val;
GOand query2:
SELECT n, (SELECT val FROM dbo.AddOneInline(n)) AS r
FROM dbo.T1
ORDER BY r;and defination of function is:
GO
CREATE FUNCTION dbo.AddOneInline(@n AS BIGINT) RETURNS TABLE
AS
RETURN SELECT @n + 1 AS val;
GOquery 2 is very good in performance and i want to know whats difference between in this two query
The difference is that one is written out as a subquery. It's a micro-optimization IMHO, but you can use the Management Studio[^] to check the execution plan and compare both versions.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]