SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Scalar Functions x Table Functions


Scalar Functions x Table Functions

Author
Message
Luiz-458831
Luiz-458831
Old Hand
Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)

Group: General Forum Members
Points: 306 Visits: 646
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.
MannySingh
MannySingh
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2139 Visits: 787
Check this good discussion here:
http://www.sqlservercentral.com/Forums/Topic446308-360-1.aspx

Maninder
www.dbanation.com
GSquared
GSquared
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40653 Visits: 9730
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
SQL_ABD
SQL_ABD
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1908 Visits: 1349
Hi,
Compare the execution plan.
You will see the which provide the best performance for your case.

Regards.
Luiz-458831
Luiz-458831
Old Hand
Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)

Group: General Forum Members
Points: 306 Visits: 646
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search