December 12, 2005 at 5:54 pm
I take your point.
I built another test:
CREATE TABLE #Names (OName sysname COLLATE SQL_Latin1_General_CP1_CI_AS)
INSERT INTO #Names
select o.name from sysobjects o, sysobjects o1
-- (839056 row(s) affected)
SELECT Object_ID(OName) as [Id] from #Names
-- run time 41 sec.
select Id from sysobjects inner join #Names on OName = Name
-- run time 12 sec.
--DROP TABLE #Names
Shoul we now avoid to use function Object_Id() ?
_____________
Code for TallyGenerator
December 12, 2005 at 6:23 pm
I understand these tests that we are performing, and I agree that it is good to do these. But I am still having a hard time understanding the basics of UDFs vs. inline SQL with regards to performance. What I do understand is that SQL Server uses an internal cursor with UDFs and inline SQL does not. Also, SQL Server cannot use parallelism with a UDF and inline SQL can. Most of these tests have been on single CPU machines. When you have complex queries that use parallelism and are faster using parallelism and you force SQL Server to use ONLY ONE processor by adding a UDF and the performance is degraded, why would anyone want that behavior. In my earlier post, I recommended to use Scalar UDFs carefully and strategically. Until the creators of SQL Server tell me or I see differences in how the optimizer works with Scalar UDFs, I will probably shy away from them when I can.
I also asked some the of MS SQL Server Developers during the SQL Pass 04 conference if this was going to be fixed, and they replied, "NO." If you want parallelism with Scalar UDFs, then build a CLR Function.
This has been fun and interesting as I have had performance issues as far back as I remember with Scalar UDFs. I am not against UDFs, I just like to use common sense when it comes to scalability and performance.
Thanks
~ Greg
December 12, 2005 at 6:49 pm
You are clearly wrong about UDF and parallelism.
Here was a test where I compared using of 4 CPU and single CPU servers by UDF and inline SQL .
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=238981&p=3
_____________
Code for TallyGenerator
December 12, 2005 at 7:45 pm
I guess we're saying the same thing. It's like trying to prove that a cursor is slower than a set based approach. We all know that, no need to add another proof.
December 12, 2005 at 7:48 pm
But are you ready to declare:
"Don't ever use function Object_Id()"
based on this test?
That's what Carl is trying to do.
_____________
Code for TallyGenerator
December 12, 2005 at 7:52 pm
I'm ready to say never try to formulate an unilateral rule in sql server without making sure it applies in that situation .
December 13, 2005 at 6:44 am
Sergiy,
Are you referring to this result...
SELECT dbo.TrimZeros (col1)
from #Var
1. 06 s
2. 24 s
...as an indication that parrallelism was working? Any chance the performance advantage was due to 3 times more RAM and RAID HD(s)?
Your debate with Gregg sparked my interest because it could be a very good example of a way to improve SQL by using the CLR.
December 13, 2005 at 9:27 am
Greg
Viewing 8 posts - 46 through 52 (of 52 total)
You must be logged in to reply to this topic. Login to reply