July 4, 2005 at 9:28 am
Dear Friends,
I wanted to know which are faster Functions/Procedures.
With Reasons.
regards
shown
July 4, 2005 at 9:43 am
Depends how you use them... this is really where you make the choice. The server will still optimize the query equally in each object.
Did you have a case scenario in mind?
July 4, 2005 at 9:52 am
Dear Remi,
I don't have a specific scenario.
This Question was asked to me for an interview.
If possible will U be able to say some scenarios where Functions are faster than procedures or vice versa.
regards
shown
July 4, 2005 at 10:11 am
There's none really. Functions are meant to either return a table or a scalar value. Sp can do the same thing but they can't be used in a select statement. Also functions cannot insert/update/delete into permanent tables which is a big difference with procs.
It's like asking which is faster, a screw driver or a hammer >> depends on the job . you'd be better off asking when it's better to use which objects or the difference I've mentioned (there are many others).
July 4, 2005 at 10:30 am
Dear Remi,
Even I had the same answer as U told.
But the interviewer made me think in a way one of them is faster than the other.
regards
shown
July 4, 2005 at 11:11 am
If you prove he's wrong then I think you get the job .
July 5, 2005 at 11:23 am
UDF performs a row by row processing, so you might suffer a performce hit on big table...
July 5, 2005 at 11:28 am
If wants to use a table function as if it were a parametered view :
Select col1, col2 from dbo.fnvwBigFastQuery(DateRange), not the other way around.
July 5, 2005 at 11:33 am
Nevermind, wrong thread .
July 6, 2005 at 10:21 am
Both are exactly the same speed just you use them differently
create proc XX
as
select count(*) from sysobjects where type = 'U'
go
create function YY ()
returns int
as
begin
return(select count(*) from sysobjects where type = 'U')
end
exec xx
or
select dbo.yy()
Bye
Gabor
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply