Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Scalar Functions x Table Functions Expand / Collapse
Author
Message
Posted Wednesday, June 25, 2008 12:11 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, December 18, 2014 7:35 AM
Points: 74, Visits: 549
Hi everyone,

In the following scenarios, does anybody know if there is a difference in performance?
The first uses a SCALAR FUNCTION, while the second uses a TABLE FUNCTION.

SELECT t1.Code, t1.Description, fn_ScalarFunction1(t1.Code) as xyz
FROM Table1 t1
WHERE ….


SELECT t1.Code, t1.Description, f1.xyz
FROM Table1 t1
OUTER APPLY fn_TableFunction1(t1.Code) as f1
WHERE ….

I was wondering if we can say that one is always better than the other, or if it depends on something else.

Thanks a lot,
Luiz.
Post #523611
Posted Wednesday, June 25, 2008 12:46 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Friday, August 15, 2014 11:42 AM
Points: 646, Visits: 732
Check this good discussion here:
http://www.sqlservercentral.com/Forums/Topic446308-360-1.aspx


Maninder
www.dbanation.com
Post #523632
Posted Wednesday, June 25, 2008 1:01 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Thursday, December 18, 2014 9:58 AM
Points: 13,872, Visits: 9,600
It depends on what you are trying to do in the function.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #523650
Posted Wednesday, June 25, 2008 1:05 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, September 3, 2014 2:52 PM
Points: 1,326, Visits: 1,289
Hi,
Compare the execution plan.
You will see the which provide the best performance for your case.

Regards.
Post #523651
Posted Wednesday, June 25, 2008 1:33 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, December 18, 2014 7:35 AM
Points: 74, Visits: 549
Thank you for your answers.

As pointed, http://www.sqlservercentral.com/Forums/Topic446308-360-1.aspx covers this issue. I'll add my new questions to it.

Luiz.
Post #523671
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse